+
+ def _CreateFlowSlices(self):
+ if len(self._all_flow_events) == 0:
+ return
+
+ self._all_flow_events.sort(
+ cmp=lambda x, y: int(x['event']['ts'] - y['event']['ts']))
+
+ flow_id_to_event = {}
+ for data in self._all_flow_events:
+ event = data['event']
+ thread = data['thread']
+ if 'name' not in event:
+ self._model.import_errors.append(
+ 'Flow events (ph: s, t or f) require a name parameter.')
+ continue
+ if 'id' not in event:
+ self._model.import_errors.append(
+ 'Flow events (ph: s, t or f) require an id parameter.')
+ continue
+
+ flow_event = tracing_flow_event.FlowEvent(
+ event['cat'],
+ event['id'],
+ event['name'],
+ event['ts'] / 1000.0,
+ event['args'])
+ thread.AddFlowEvent(flow_event)
+
+ if event['ph'] == 's':
+ if event['id'] in flow_id_to_event:
+ self._model.import_errors.append(
+ 'event id %s already seen when encountering start of'
+ 'flow event.' % event['id'])
+ continue
+ flow_id_to_event[event['id']] = flow_event
+ elif event['ph'] == 't' or event['ph'] == 'f':
+ if not event['id'] in flow_id_to_event:
+ self._model.import_errors.append(
+ 'Found flow phase %s for id: %s but no flow start found.' % (
+ event['ph'], event['id']))
+ continue
+ flow_position = flow_id_to_event[event['id']]
+ self._model.flow_events.append([flow_position, flow_event])
+
+ if event['ph'] == 'f':
+ del flow_id_to_event[event['id']]
+ else:
+ # Make this event the next start event in this flow.
+ flow_id_to_event[event['id']] = flow_event