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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome/inspector_backend_list.py

Issue 578693002: Revert of Revert of Introduce GetBackendFromContextId to avoid using list index. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/extension_backend.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/backends/chrome/inspector_backend_list.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/inspector_backend_list.py b/tools/telemetry/telemetry/core/backends/chrome/inspector_backend_list.py
index 2f7385ee197d89bb8cb0692afaa8472b00933932..66547b005fef3cc3aec2adbab8244a996d1ad1c1 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/inspector_backend_list.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/inspector_backend_list.py
@@ -42,6 +42,8 @@
"""Override this method to control which contexts are included."""
return True
+ #TODO(nednguyen): Remove this method and turn inspector_backend_list API to
+ # dictionary-like API (crbug.com/398467)
def __getitem__(self, index):
self._Update()
if index >= len(self._inspectable_contexts_dict.keys()):
@@ -51,6 +53,12 @@
"keys": self._inspectable_contexts_dict.keys()
}))
context_id = self._inspectable_contexts_dict.keys()[index]
+ return self.GetBackendFromContextId(context_id)
+
+ def GetBackendFromContextId(self, context_id):
+ self._Update()
+ if context_id not in self._inspectable_contexts_dict:
+ raise KeyError('Cannot find a context with id=%s' % context_id)
if context_id not in self._inspector_backend_dict:
backend = inspector_backend.InspectorBackend(
self._browser_backend,
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/extension_backend.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698