OLD | NEW |
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 import util | |
11 from telemetry.core.backends.chrome_inspector import devtools_http | 10 from telemetry.core.backends.chrome_inspector import devtools_http |
12 | 11 |
13 | 12 |
14 class FastNavigationProfileExtender(object): | 13 class FastNavigationProfileExtender(object): |
15 """Extends a Chrome profile. | 14 """Extends a Chrome profile. |
16 | 15 |
17 This class creates or extends an existing profile by performing a set of tab | 16 This class creates or extends an existing profile by performing a set of tab |
18 navigations in large batches. This is accomplished by opening a large number | 17 navigations in large batches. This is accomplished by opening a large number |
19 of tabs, simultaneously navigating all the tabs, and then waiting for all the | 18 of tabs, simultaneously navigating all the tabs, and then waiting for all the |
20 tabs to load. This provides two benefits: | 19 tabs to load. This provides two benefits: |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 232 |
234 # Since we don't wait any time for the tab url navigation to commit, it's | 233 # Since we don't wait any time for the tab url navigation to commit, it's |
235 # possible that the tab hasn't started navigating yet. | 234 # possible that the tab hasn't started navigating yet. |
236 self._WaitForUrlToChange(tab, initial_url, seconds_to_wait) | 235 self._WaitForUrlToChange(tab, initial_url, seconds_to_wait) |
237 | 236 |
238 seconds_to_wait = end_time - time.time() | 237 seconds_to_wait = end_time - time.time() |
239 seconds_to_wait = max(0, seconds_to_wait) | 238 seconds_to_wait = max(0, seconds_to_wait) |
240 | 239 |
241 try: | 240 try: |
242 tab.WaitForDocumentReadyStateToBeComplete(seconds_to_wait) | 241 tab.WaitForDocumentReadyStateToBeComplete(seconds_to_wait) |
243 except util.TimeoutException: | 242 except exceptions.TimeoutException: |
244 # Ignore time outs. | 243 # Ignore time outs. |
245 pass | 244 pass |
246 except (exceptions.DevtoolsTargetCrashException, | 245 except (exceptions.DevtoolsTargetCrashException, |
247 devtools_http.DevToolsClientConnectionError, | 246 devtools_http.DevToolsClientConnectionError, |
248 devtools_http.DevToolsClientUrlError): | 247 devtools_http.DevToolsClientUrlError): |
249 # 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 |
250 # unrecoverable state. | 249 # unrecoverable state. |
251 self._RemoveNavigationTab(tab) | 250 self._RemoveNavigationTab(tab) |
252 | 251 |
253 def _GetUrlsToNavigate(self, url_iterator): | 252 def _GetUrlsToNavigate(self, url_iterator): |
(...skipping 25 matching lines...) Expand all Loading... |
279 tab = self._navigation_tabs[i] | 278 tab = self._navigation_tabs[i] |
280 batch.append((tab, url)) | 279 batch.append((tab, url)) |
281 | 280 |
282 queued_tabs = self._BatchNavigateTabs(batch) | 281 queued_tabs = self._BatchNavigateTabs(batch) |
283 self._WaitForQueuedTabsToLoad(queued_tabs) | 282 self._WaitForQueuedTabsToLoad(queued_tabs) |
284 | 283 |
285 self.CleanUpAfterBatchNavigation() | 284 self.CleanUpAfterBatchNavigation() |
286 | 285 |
287 if self.ShouldExitAfterBatchNavigation(): | 286 if self.ShouldExitAfterBatchNavigation(): |
288 break | 287 break |
OLD | NEW |