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/core/backends/chrome/misc_web_contents_backend.py

Issue 165693006: [Telemetry] Factor out common logic between inspector backend lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments Created 6 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/misc_web_contents_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/misc_web_contents_backend.py b/tools/telemetry/telemetry/core/backends/chrome/misc_web_contents_backend.py
index 933010e267ae04376b3f5d7241876c183bbc3390..7eb08568f93920ea8d571d64984d42c48ea98166 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/misc_web_contents_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/misc_web_contents_backend.py
@@ -1,47 +1,30 @@
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import json
-from telemetry.core import exceptions
from telemetry.core import web_contents
-from telemetry.core.backends.chrome import inspector_backend
+from telemetry.core.backends.chrome import inspector_backend_list
+
+
+class MiscWebContentsBackend(inspector_backend_list.InspectorBackendList):
+ """A dynamic sequence of web contents not related to tabs and extensions.
+
+ Provides acccess to chrome://oobe/login page.
+ """
-class MiscWebContentsBackend(object):
- """Provides acccess to chrome://oobe/login page, which is neither an extension
- nor a tab."""
def __init__(self, browser_backend):
- self._browser_backend = browser_backend
+ super(MiscWebContentsBackend, self).__init__(
+ browser_backend, backend_wrapper=web_contents.WebContents)
@property
def oobe_exists(self):
"""Lightweight property to determine if the oobe webui is visible."""
- return bool(self._FindWebContentsInfo())
+ return bool(len(self))
def GetOobe(self):
- oobe_web_contents_info = self._FindWebContentsInfo()
- if oobe_web_contents_info:
- debugger_url = oobe_web_contents_info.get('webSocketDebuggerUrl')
- if debugger_url:
- try:
- inspector = self._CreateInspectorBackend(debugger_url)
- except exceptions.TabCrashException:
- return None
- return web_contents.WebContents(inspector)
- return None
-
- def _CreateInspectorBackend(self, debugger_url):
- return inspector_backend.InspectorBackend(self._browser_backend.browser,
- self._browser_backend,
- debugger_url)
-
- def _ListWebContents(self, timeout=None):
- data = self._browser_backend.Request('', timeout=timeout)
- return json.loads(data)
-
- def _FindWebContentsInfo(self):
- for web_contents_info in self._ListWebContents():
- # Prior to crrev.com/203152, url was chrome://oobe/login.
- if (web_contents_info.get('url').startswith('chrome://oobe')):
- return web_contents_info
- return None
+ if not len(self):
+ return None
+ return self[0]
+
+ def ShouldIncludeContext(self, context):
+ return context.get('url').startswith('chrome://oobe')

Powered by Google App Engine
This is Rietveld 408576698