| 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 | 4 |
| 5 import collections | 5 import collections |
| 6 | 6 |
| 7 from measurements import startup | 7 from measurements import startup |
| 8 from metrics import cpu | 8 from metrics import cpu |
| 9 from metrics import startup_metric | 9 from metrics import startup_metric |
| 10 from telemetry.core import util | 10 from telemetry.core import util |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 histogram_util.BROWSER_HISTOGRAM, | 39 histogram_util.BROWSER_HISTOGRAM, |
| 40 'SessionRestore.AllTabsLoaded', | 40 'SessionRestore.AllTabsLoaded', |
| 41 browser.foreground_tab), | 41 browser.foreground_tab), |
| 42 60) | 42 60) |
| 43 return browser.foreground_tab | 43 return browser.foreground_tab |
| 44 | 44 |
| 45 def RunNavigateSteps(self, page, tab): | 45 def RunNavigateSteps(self, page, tab): |
| 46 # Overridden so that no page navigation occurs. | 46 # Overridden so that no page navigation occurs. |
| 47 pass | 47 pass |
| 48 | 48 |
| 49 def ValidatePageSet(self, page_set): | |
| 50 wpr_archive_names_to_page_urls = collections.defaultdict(list) | |
| 51 # Construct the map from pages' wpr archive names to pages' urls. | |
| 52 for page in page_set: | |
| 53 if page.is_local: | |
| 54 continue | |
| 55 wpr_archive_name = page_set.WprFilePathForUserStory(page) | |
| 56 wpr_archive_names_to_page_urls[wpr_archive_name].append(page.url) | |
| 57 | |
| 58 # Reject any pageset that contains more than one WPR archive. | |
| 59 if len(wpr_archive_names_to_page_urls.keys()) > 1: | |
| 60 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + | |
| 61 repr(wpr_archive_names_to_page_urls)) | |
| 62 | |
| 63 def DidStartBrowser(self, browser): | 49 def DidStartBrowser(self, browser): |
| 64 self._cpu_metric = cpu.CpuMetric(browser) | 50 self._cpu_metric = cpu.CpuMetric(browser) |
| 65 self._cpu_metric.Start(None, None) | 51 self._cpu_metric.Start(None, None) |
| 66 | 52 |
| 67 def ValidateAndMeasurePage(self, page, tab, results): | 53 def ValidateAndMeasurePage(self, page, tab, results): |
| 68 tab.WaitForDocumentReadyStateToBeComplete() | 54 tab.WaitForDocumentReadyStateToBeComplete() |
| 69 super(SessionRestore, self).ValidateAndMeasurePage(page, tab, results) | 55 super(SessionRestore, self).ValidateAndMeasurePage(page, tab, results) |
| 70 | 56 |
| 71 # Record CPU usage from browser start to when the foreground page is loaded. | 57 # Record CPU usage from browser start to when the foreground page is loaded. |
| 72 self._cpu_metric.Stop(None, None) | 58 self._cpu_metric.Stop(None, None) |
| 73 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') | 59 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') |
| 74 | 60 |
| 75 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. | 61 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. |
| OLD | NEW |