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

Side by Side Diff: tools/perf/profile_creators/fast_navigation_profile_extender.py

Issue 959423003: Telemetry: Add more details to inspector_backend exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@telemetry_make_new_exceptions4
Patch Set: Rebase against top of tree. Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import time 4 import time
5 5
6 from telemetry.core import browser_finder 6 from telemetry.core import browser_finder
7 from telemetry.core import browser_finder_exceptions 7 from telemetry.core import browser_finder_exceptions
8 from telemetry.core import exceptions 8 from telemetry.core import exceptions
9 from telemetry.core import platform 9 from telemetry.core import platform
10 from telemetry.core.backends.chrome_inspector import devtools_http 10 from telemetry.core.backends.chrome_inspector import devtools_http
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) 154 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options)))
155 finder_options.browser_options.browser_type = ( 155 finder_options.browser_options.browser_type = (
156 possible_browser.browser_type) 156 possible_browser.browser_type)
157 157
158 return possible_browser 158 return possible_browser
159 159
160 def _RetrieveTabUrl(self, tab, timeout): 160 def _RetrieveTabUrl(self, tab, timeout):
161 """Retrives the URL of the tab.""" 161 """Retrives the URL of the tab."""
162 try: 162 try:
163 return tab.EvaluateJavaScript('document.URL', timeout) 163 return tab.EvaluateJavaScript('document.URL', timeout)
164 except (exceptions.DevtoolsTargetCrashException, 164 except (exceptions.Error,
165 devtools_http.DevToolsClientConnectionError, 165 devtools_http.DevToolsClientConnectionError,
166 devtools_http.DevToolsClientUrlError): 166 devtools_http.DevToolsClientUrlError):
167 return None 167 return None
168 168
169 def _WaitForUrlToChange(self, tab, initial_url, timeout): 169 def _WaitForUrlToChange(self, tab, initial_url, timeout):
170 """Waits for the tab to navigate away from its initial url.""" 170 """Waits for the tab to navigate away from its initial url."""
171 end_time = time.time() + timeout 171 end_time = time.time() + timeout
172 while True: 172 while True:
173 seconds_to_wait = end_time - time.time() 173 seconds_to_wait = end_time - time.time()
174 seconds_to_wait = max(0, seconds_to_wait) 174 seconds_to_wait = max(0, seconds_to_wait)
(...skipping 22 matching lines...) Expand all
197 """ 197 """
198 timeout_in_seconds = 0 198 timeout_in_seconds = 0
199 199
200 queued_tabs = [] 200 queued_tabs = []
201 for tab, url in batch: 201 for tab, url in batch:
202 initial_url = self._RetrieveTabUrl(tab, 202 initial_url = self._RetrieveTabUrl(tab,
203 self._TAB_URL_RETRIEVAL_TIMEOUT_IN_SECONDS) 203 self._TAB_URL_RETRIEVAL_TIMEOUT_IN_SECONDS)
204 204
205 try: 205 try:
206 tab.Navigate(url, None, timeout_in_seconds) 206 tab.Navigate(url, None, timeout_in_seconds)
207 except (exceptions.DevtoolsTargetCrashException, 207 except (exceptions.Error,
208 devtools_http.DevToolsClientConnectionError, 208 devtools_http.DevToolsClientConnectionError,
209 devtools_http.DevToolsClientUrlError): 209 devtools_http.DevToolsClientUrlError):
210 # We expect a time out. It's possible for other problems to arise, but 210 # We expect a time out. It's possible for other problems to arise, but
211 # this method is not responsible for dealing with them. Ignore all 211 # this method is not responsible for dealing with them. Ignore all
212 # exceptions. 212 # exceptions.
213 pass 213 pass
214 214
215 queued_tabs.append((tab, initial_url)) 215 queued_tabs.append((tab, initial_url))
216 return queued_tabs 216 return queued_tabs
217 217
(...skipping 17 matching lines...) Expand all
235 self._WaitForUrlToChange(tab, initial_url, seconds_to_wait) 235 self._WaitForUrlToChange(tab, initial_url, seconds_to_wait)
236 236
237 seconds_to_wait = end_time - time.time() 237 seconds_to_wait = end_time - time.time()
238 seconds_to_wait = max(0, seconds_to_wait) 238 seconds_to_wait = max(0, seconds_to_wait)
239 239
240 try: 240 try:
241 tab.WaitForDocumentReadyStateToBeComplete(seconds_to_wait) 241 tab.WaitForDocumentReadyStateToBeComplete(seconds_to_wait)
242 except exceptions.TimeoutException: 242 except exceptions.TimeoutException:
243 # Ignore time outs. 243 # Ignore time outs.
244 pass 244 pass
245 except (exceptions.DevtoolsTargetCrashException, 245 except (exceptions.Error,
246 devtools_http.DevToolsClientConnectionError, 246 devtools_http.DevToolsClientConnectionError,
247 devtools_http.DevToolsClientUrlError): 247 devtools_http.DevToolsClientUrlError):
248 # If any error occurs, remove the tab. it's probably in an 248 # If any error occurs, remove the tab. it's probably in an
249 # unrecoverable state. 249 # unrecoverable state.
250 self._RemoveNavigationTab(tab) 250 self._RemoveNavigationTab(tab)
251 251
252 def _GetUrlsToNavigate(self, url_iterator): 252 def _GetUrlsToNavigate(self, url_iterator):
253 """Returns an array of urls to navigate to, given a url_iterator.""" 253 """Returns an array of urls to navigate to, given a url_iterator."""
254 urls = [] 254 urls = []
255 for _ in xrange(self._NUM_TABS): 255 for _ in xrange(self._NUM_TABS):
(...skipping 22 matching lines...) Expand all
278 tab = self._navigation_tabs[i] 278 tab = self._navigation_tabs[i]
279 batch.append((tab, url)) 279 batch.append((tab, url))
280 280
281 queued_tabs = self._BatchNavigateTabs(batch) 281 queued_tabs = self._BatchNavigateTabs(batch)
282 self._WaitForQueuedTabsToLoad(queued_tabs) 282 self._WaitForQueuedTabsToLoad(queued_tabs)
283 283
284 self.CleanUpAfterBatchNavigation() 284 self.CleanUpAfterBatchNavigation()
285 285
286 if self.ShouldExitAfterBatchNavigation(): 286 if self.ShouldExitAfterBatchNavigation():
287 break 287 break
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698