OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 from measurements import timeline_controller | 4 from measurements import timeline_controller |
5 from metrics import loading | 5 from metrics import loading |
6 from metrics import timeline | 6 from metrics import timeline |
7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
8 from telemetry.web_perf import timeline_interaction_record as tir_module | 8 from telemetry.web_perf import timeline_interaction_record as tir_module |
9 | 9 |
10 class LoadingTrace(page_measurement.PageMeasurement): | 10 class LoadingTrace(page_measurement.PageMeasurement): |
11 def __init__(self, *args, **kwargs): | 11 def __init__(self, *args, **kwargs): |
12 super(LoadingTrace, self).__init__(*args, **kwargs) | 12 super(LoadingTrace, self).__init__(*args, **kwargs) |
13 self._timeline_controller = timeline_controller.TimelineController() | 13 self._timeline_controller = timeline_controller.TimelineController() |
14 | 14 |
15 def WillNavigateToPage(self, page, tab): | 15 def WillNavigateToPage(self, page, tab): |
16 self._timeline_controller.SetUp(page, tab) | 16 self._timeline_controller.SetUp(page, tab) |
17 self._timeline_controller.Start(tab) | 17 self._timeline_controller.Start(tab) |
18 | 18 |
19 def MeasurePage(self, page, tab, results): | 19 def MeasurePage(self, page, tab, results): |
20 # In current telemetry tests, all tests wait for DocumentComplete state, | 20 # In current telemetry tests, all tests wait for DocumentComplete state, |
21 # but we need to wait for the load event. | 21 # but we need to wait for the load event. |
22 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) | 22 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) |
23 | 23 |
24 # TODO(nduca): when crbug.com/168431 is fixed, modify the page sets to | 24 # TODO(nduca): when crbug.com/168431 is fixed, modify the page sets to |
25 # recognize loading as a toplevel action. | 25 # recognize loading as a toplevel action. |
26 self._timeline_controller.Stop(tab) | 26 self._timeline_controller.Stop(tab) |
27 | 27 |
28 loading.LoadingMetric().AddResults(tab, results) | 28 loading.LoadingMetric().AddResults(tab, results) |
29 timeline_metric = timeline.LoadTimesTimelineMetric() | 29 timeline_metric = timeline.LoadTimesTimelineMetric() |
30 renderer_thread = \ | |
31 self._timeline_controller.model.GetRendererThreadFromTabId(tab.id) | |
32 record = tir_module.TimelineInteractionRecord( | 30 record = tir_module.TimelineInteractionRecord( |
33 "loading_trace_interaction", 0, float('inf')) | 31 "loading_trace_interaction", 0, float('inf')) |
34 timeline_metric.AddResults( | 32 timeline_metric.AddResults( |
35 self._timeline_controller.model, | 33 self._timeline_controller.model, |
36 renderer_thread, | |
37 [record], | 34 [record], |
38 results) | 35 results) |
39 | 36 |
40 def CleanUpAfterPage(self, _, tab): | 37 def CleanUpAfterPage(self, _, tab): |
41 self._timeline_controller.CleanUp(tab) | 38 self._timeline_controller.CleanUp(tab) |
OLD | NEW |