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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_page.py

Issue 942113004: Telemetry: Refactor inspector_websocket to create cleaner interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from slamm. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_page.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_page.py b/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_page.py
index aa682fe39af86ff5f569854a444d6fba632b3598..f56903cc16df1f8d9411cc6e6118f225a41a21e5 100644
--- a/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_page.py
+++ b/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_page.py
@@ -9,6 +9,12 @@ from telemetry.image_processing import image_util
class InspectorPage(object):
+ """Class that controls a page connected by an inspector_websocket.
+
+ This class provides utility methods for controlling a page connected by an
+ inspector_websocket. It does not perform any exception handling. All
+ inspector_websocket exceptions must be handled by the caller.
+ """
def __init__(self, inspector_websocket, timeout=60):
self._inspector_websocket = inspector_websocket
self._inspector_websocket.RegisterDomain('Page', self._OnNotification)
@@ -85,15 +91,9 @@ class InspectorPage(object):
start_time = time.time()
remaining_time = timeout
self._navigation_pending = True
- try:
- while self._navigation_pending and remaining_time > 0:
- remaining_time = max(timeout - (time.time() - start_time), 0.0)
- self._inspector_websocket.DispatchNotifications(remaining_time)
- except util.TimeoutException:
- # Since we pass remaining_time to DispatchNotifications, we need to
- # list the full timeout time in this message.
- raise util.TimeoutException('Timed out while waiting %ds for navigation. '
- 'Error=%s' % (timeout, sys.exc_info()[1]))
+ while self._navigation_pending and remaining_time > 0:
+ remaining_time = max(timeout - (time.time() - start_time), 0.0)
+ self._inspector_websocket.DispatchNotifications(remaining_time)
def Navigate(self, url, script_to_evaluate_on_commit=None, timeout=60):
"""Navigates to |url|.

Powered by Google App Engine
This is Rietveld 408576698