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

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: 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
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..76ce7d1fa371a0fc59926eef16f2ecae1b99397f 100644
--- a/tools/telemetry/telemetry/browser_backend.py
+++ b/tools/telemetry/telemetry/browser_backend.py
@@ -7,6 +7,7 @@ import socket
import json
from telemetry import browser_gone_exception
+from telemetry import connection_gone_exception
from telemetry import inspector_backend
from telemetry import tab
from telemetry import user_agent
@@ -42,17 +43,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 connection_gone_exception.ConnectionGoneException:
return False
else:
return True
@@ -66,17 +57,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 connection_gone_exception.ConnectionGoneException()
def NewTab(self, timeout=None):
req = urllib2.urlopen(self._debugger_url + '/new', timeout=timeout)

Powered by Google App Engine
This is Rietveld 408576698