| 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 from measurements import startup | 5 from measurements import startup |
| 6 from metrics import cpu | 6 from metrics import cpu |
| 7 from metrics import startup_metric | 7 from metrics import startup_metric |
| 8 | 8 |
| 9 | 9 |
| 10 class SessionRestore(startup.Startup): | 10 class SessionRestore(startup.Startup): |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 return page.page_set.pages.index(page) == 0 | 31 return page.page_set.pages.index(page) == 0 |
| 32 | 32 |
| 33 def RunNavigateSteps(self, page, tab): | 33 def RunNavigateSteps(self, page, tab): |
| 34 # Overriden so that no page navigation occurs. | 34 # Overriden so that no page navigation occurs. |
| 35 pass | 35 pass |
| 36 | 36 |
| 37 def ValidatePageSet(self, page_set): | 37 def ValidatePageSet(self, page_set): |
| 38 # Reject any pageset that contains more than one WPR archive. | 38 # Reject any pageset that contains more than one WPR archive. |
| 39 wpr_archives = {} | 39 wpr_archives = {} |
| 40 for page in page_set: | 40 for page in page_set: |
| 41 wpr_archives[page_set.WprFilePathForPage(page)] = True | 41 if not page.is_local: |
| 42 wpr_archives[page_set.WprFilePathForPage(page)] = True |
| 42 | 43 |
| 43 if len(wpr_archives.keys()) > 1: | 44 if len(wpr_archives.keys()) > 1: |
| 44 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + | 45 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + |
| 45 ', '.join(wpr_archives.keys())) | 46 ', '.join(wpr_archives.keys())) |
| 46 | 47 |
| 47 def DidStartBrowser(self, browser): | 48 def DidStartBrowser(self, browser): |
| 48 self._cpu_metric = cpu.CpuMetric(browser) | 49 self._cpu_metric = cpu.CpuMetric(browser) |
| 49 self._cpu_metric.Start(None, None) | 50 self._cpu_metric.Start(None, None) |
| 50 | 51 |
| 51 def MeasurePage(self, page, tab, results): | 52 def MeasurePage(self, page, tab, results): |
| 52 # Wait for all tabs to finish loading. | 53 # Wait for all tabs to finish loading. |
| 53 for i in xrange(len(tab.browser.tabs)): | 54 for i in xrange(len(tab.browser.tabs)): |
| 54 t = tab.browser.tabs[i] | 55 t = tab.browser.tabs[i] |
| 55 t.WaitForDocumentReadyStateToBeComplete() | 56 t.WaitForDocumentReadyStateToBeComplete() |
| 56 | 57 |
| 57 # Record CPU usage from browser start to when all pages have loaded. | 58 # Record CPU usage from browser start to when all pages have loaded. |
| 58 self._cpu_metric.Stop(None, None) | 59 self._cpu_metric.Stop(None, None) |
| 59 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') | 60 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') |
| 60 | 61 |
| 61 startup_metric.StartupMetric().AddResults(tab, results) | 62 startup_metric.StartupMetric().AddResults(tab, results) |
| 62 | 63 |
| 63 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. | 64 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. |
| OLD | NEW |