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

Unified Diff: tools/telemetry/telemetry/browser_backend.py

Issue 11348370: [Telemetry] Fix a possible source of flakiness on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: BrowserConnectionGoneException subclasses BrowserGoneException Created 8 years 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
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page_runner.py » ('j') | tools/telemetry/telemetry/page_runner.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/browser_backend.py
diff --git a/tools/telemetry/telemetry/browser_backend.py b/tools/telemetry/telemetry/browser_backend.py
index b45919dd237c2d5c92e5d358f6f05432512e7a6e..bb9b6e7530732da44c9ea867fd630c4328c769e0 100644
--- a/tools/telemetry/telemetry/browser_backend.py
+++ b/tools/telemetry/telemetry/browser_backend.py
@@ -14,6 +14,12 @@ from telemetry import util
from telemetry import wpr_modes
from telemetry import wpr_server
+
+class BrowserConnectionGoneException(
+ browser_gone_exception.BrowserGoneException):
+ pass
+
+
class BrowserBackend(object):
"""A base class for browser backends. Provides basic functionality
once a remote-debugger port has been established."""
@@ -42,17 +48,7 @@ class BrowserBackend(object):
def IsBrowserUp():
try:
self._ListTabs()
- except socket.error:
- if not self.IsBrowserRunning():
- raise browser_gone_exception.BrowserGoneException()
- return False
- except httplib.BadStatusLine:
- if not self.IsBrowserRunning():
- raise browser_gone_exception.BrowserGoneException()
- return False
- except urllib2.URLError:
- if not self.IsBrowserRunning():
- raise browser_gone_exception.BrowserGoneException()
+ except BrowserConnectionGoneException:
return False
else:
return True
@@ -66,17 +62,22 @@ class BrowserBackend(object):
return 'http://localhost:%i/json' % self._port
def _ListTabs(self, timeout=None):
- req = urllib2.urlopen(self._debugger_url, timeout=timeout)
- data = req.read()
- all_contexts = json.loads(data)
- tabs = [ctx for ctx in all_contexts
- if not ctx['url'].startswith('chrome-extension://')]
- # FIXME(dtu): The remote debugger protocol returns in order of most
- # recently created tab first. In order to convert it to the UI tab
- # order, we just reverse the list, which assumes we can't move tabs.
- # We should guarantee that the remote debugger returns in the UI tab order.
- tabs.reverse()
- return tabs
+ try:
+ req = urllib2.urlopen(self._debugger_url, timeout=timeout)
+ data = req.read()
+ all_contexts = json.loads(data)
+ tabs = [ctx for ctx in all_contexts
+ if not ctx['url'].startswith('chrome-extension://')]
+ # FIXME(dtu): The remote debugger protocol returns in order of most
+ # recently created tab first. In order to convert it to the UI tab
+ # order, we just reverse the list, which assumes we can't move tabs.
+ # We should guarantee that the remote debugger returns in UI tab order.
+ tabs.reverse()
+ return tabs
+ except (socket.error, httplib.BadStatusLine, urllib2.URLError):
+ if not self.IsBrowserRunning():
+ raise browser_gone_exception.BrowserGoneException()
+ raise BrowserConnectionGoneException()
def NewTab(self, timeout=None):
req = urllib2.urlopen(self._debugger_url + '/new', timeout=timeout)
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page_runner.py » ('j') | tools/telemetry/telemetry/page_runner.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698