Chromium Code Reviews| 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 logging | 5 import logging |
| 6 import pprint | 6 import pprint |
| 7 import shlex | 7 import shlex |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from telemetry.core import exceptions | 10 from telemetry.core import exceptions |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 # and installed a root certificate. | 132 # and installed a root certificate. |
| 133 replay_args.append('--ignore-certificate-errors') | 133 replay_args.append('--ignore-certificate-errors') |
| 134 return replay_args | 134 return replay_args |
| 135 | 135 |
| 136 def HasBrowserFinishedLaunching(self): | 136 def HasBrowserFinishedLaunching(self): |
| 137 assert self._port, 'No DevTools port info available.' | 137 assert self._port, 'No DevTools port info available.' |
| 138 return devtools_client_backend.IsDevToolsAgentAvailable( | 138 return devtools_client_backend.IsDevToolsAgentAvailable( |
| 139 self._port, | 139 self._port, |
| 140 self._browser_target, self) | 140 self._browser_target, self) |
| 141 | 141 |
| 142 def _InitDevtoolsClientBackend(self, remote_devtools_port=None): | 142 def _WaitForBrowserToComeUp(self, remote_devtools_port=None): |
| 143 """ Initiate the devtool client backend which allow browser connection | 143 """ Wait for browser to come up. |
|
achuithb
2017/08/09 21:32:48
Let's add a comment here saying that we're also cr
pfeldman
2017/08/09 21:46:19
I think it is fine for client creation to be a by
achuithb
2017/08/09 21:53:26
Acknowledged.
Makes sense to me - let's see if Ne
| |
| 144 through browser' devtool. | |
| 145 | 144 |
| 146 Args: | 145 Args: |
| 147 remote_devtools_port: The remote devtools port, if | 146 remote_devtools_port: The remote devtools port, if |
| 148 any. Otherwise assumed to be the same as self._port. | 147 any. Otherwise assumed to be the same as self._port. |
| 149 """ | 148 """ |
| 150 assert not self._devtools_client, ( | |
| 151 'Devtool client backend cannot be init twice') | |
| 152 self._devtools_client = devtools_client_backend.DevToolsClientBackend( | |
| 153 self._port, self._browser_target, | |
| 154 remote_devtools_port or self._port, self) | |
| 155 | |
| 156 def _WaitForBrowserToComeUp(self): | |
| 157 """ Wait for browser to come up. """ | |
| 158 try: | 149 try: |
| 159 timeout = self.browser_options.browser_startup_timeout | 150 timeout = self.browser_options.browser_startup_timeout |
| 160 py_utils.WaitFor(self.HasBrowserFinishedLaunching, timeout=timeout) | 151 py_utils.WaitFor(self.HasBrowserFinishedLaunching, timeout=timeout) |
| 161 except (py_utils.TimeoutException, exceptions.ProcessGoneException) as e: | 152 except (py_utils.TimeoutException, exceptions.ProcessGoneException) as e: |
| 162 if not self.IsBrowserRunning(): | 153 if not self.IsBrowserRunning(): |
| 163 raise exceptions.BrowserGoneException(self.browser, e) | 154 raise exceptions.BrowserGoneException(self.browser, e) |
| 164 raise exceptions.BrowserConnectionGoneException(self.browser, e) | 155 raise exceptions.BrowserConnectionGoneException(self.browser, e) |
| 156 self._devtools_client = devtools_client_backend.DevToolsClientBackend( | |
| 157 self._port, self._browser_target, | |
| 158 remote_devtools_port or self._port, self) | |
| 165 | 159 |
| 166 def _WaitForExtensionsToLoad(self): | 160 def _WaitForExtensionsToLoad(self): |
| 167 """ Wait for all extensions to load. | 161 """ Wait for all extensions to load. |
| 168 Be sure to check whether the browser_backend supports_extensions before | 162 Be sure to check whether the browser_backend supports_extensions before |
| 169 calling this method. | 163 calling this method. |
| 170 """ | 164 """ |
| 171 assert self._supports_extensions | 165 assert self._supports_extensions |
| 172 assert self._devtools_client, ( | 166 assert self._devtools_client, ( |
| 173 'Waiting for extensions required devtool client to be initiated first') | 167 'Waiting for extensions required devtool client to be initiated first') |
| 174 try: | 168 try: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 def supports_cpu_metrics(self): | 298 def supports_cpu_metrics(self): |
| 305 return True | 299 return True |
| 306 | 300 |
| 307 @property | 301 @property |
| 308 def supports_memory_metrics(self): | 302 def supports_memory_metrics(self): |
| 309 return True | 303 return True |
| 310 | 304 |
| 311 @property | 305 @property |
| 312 def supports_power_metrics(self): | 306 def supports_power_metrics(self): |
| 313 return True | 307 return True |
| OLD | NEW |