Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: tools/telemetry/telemetry/timeline/tab_id_importer.py

Issue 441873007: Move timeline and importers to use telemetry.value.TraceValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/timeline/tab_id_importer.py
diff --git a/tools/telemetry/telemetry/timeline/tab_id_importer.py b/tools/telemetry/telemetry/timeline/tab_id_importer.py
new file mode 100644
index 0000000000000000000000000000000000000000..cb64edc835b250ccf0c494f653b79d8d870ff0f3
--- /dev/null
+++ b/tools/telemetry/telemetry/timeline/tab_id_importer.py
@@ -0,0 +1,56 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from telemetry.timeline import importer
+from telemetry.value import trace as trace_value_module
+
+class TraceBufferOverflowException(Exception):
+ pass
+
+
+class TabIdImporter(importer.TimelineImporter):
+ def __init__(self, model, trace_value):
+ # Needs to run after all other importers so overflow events have been
+ # created on the model.
+ super(TabIdImporter, self).__init__(
+ model,
+ trace_value,
+ import_order=999)
+ self._trace_value = trace_value
+
+ @staticmethod
+ def GetSupportedPart():
+ return trace_value_module.TAB_ID_PART
+
+ def ImportEvents(self):
+ pass
+
+ def FinalizeImport(self):
+ self._CheckTraceBufferOverflow()
+ self._CreateTabIdsToThreadsMap()
+
+ def _CheckTraceBufferOverflow(self):
+ # Since _CreateTabIdsToThreadsMap() relies on markers output on timeline
+ # tracing data, it maynot work in case we have trace events dropped due to
+ # trace buffer overflow. for process in self._model.GetAllProcesses():
slamm 2014/08/12 23:11:59 Missing newline.
+
+ if process.trace_buffer_did_overflow:
+ raise TraceBufferOverflowException(
+ 'Trace buffer of process with pid=%d overflowed at timestamp %d. '
+ 'Raw trace data:\n%s' %
+ (process.pid, process.trace_buffer_overflow_event.start,
+ repr(self._events)))
+
+ def _CreateTabIdsToThreadsMap(self, trace_value):
+ tab_id_events = self._trace_value.GetEventsFor(
+ trace_value_module.TAB_ID_PART)
+
+ for tab_id in tab_id_events:
+ timeline_markers = self._model.FindTimelineMarkers(tab_id)
+ assert(len(timeline_markers) == 1)
+ assert(timeline_markers[0].start_thread ==
slamm 2014/08/12 23:11:59 Needs line continuation.
+ timeline_markers[0].end_thread)
+ self._model.AddMappingFromTabIdToRendererThread(
+ tab_id, timeline_markers[0].start_thread)
+

Powered by Google App Engine
This is Rietveld 408576698