Commit c8fad04c authored by nednguyen's avatar nednguyen Committed by Commit bot

Revert of Introduce GetBackendFromContextId to avoid using list index....

Revert of Introduce GetBackendFromContextId to avoid using list index. (patchset #1 id:1 of https://codereview.chromium.org/556003005/)

Reason for revert:
It looks like the moto E perf bots are broken due to this change.

BUG=414267

Original issue's description:
> Introduce GetBackendFromContextId to avoid using list index.
>
> BUG=398467
> TEST=ExtensionTest
>
> Committed: https://crrev.com/a1a83005087fdac70e7809f9dc1d89f6c4f88dfc
> Cr-Commit-Position: refs/heads/master@{#294455}

TBR=tbarzic@chromium.org,achuith@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=398467

Review URL: https://codereview.chromium.org/573573003

Cr-Commit-Position: refs/heads/master@{#295136}
parent f913653c
......@@ -160,11 +160,9 @@ class ChromeBrowserBackend(browser_backend.BrowserBackend):
document.readyState == 'interactive')
"""
for e in self._extensions_to_load:
try:
extension_objects = self.extension_backend[e.extension_id]
except KeyError:
if not e.extension_id in self.extension_backend:
return False
for extension_object in extension_objects:
for extension_object in self.extension_backend[e.extension_id]:
try:
res = extension_object.EvaluateJavaScript(
extension_ready_js % e.extension_id)
......
......@@ -25,12 +25,16 @@ class ExtensionBackendDict(collections.Mapping):
def __init__(self, browser_backend):
self._extension_backend_list = ExtensionBackendList(browser_backend)
def __contains__(self, extension_id):
return (extension_id in
(self.ContextIdToExtensionId(context_id)
for context_id in self._extension_backend_list))
def __getitem__(self, extension_id):
extensions = []
for context_id in self._extension_backend_list:
for i, context_id in enumerate(self._extension_backend_list):
if self.ContextIdToExtensionId(context_id) == extension_id:
extensions.append(
self._extension_backend_list.GetBackendFromContextId(context_id))
extensions.append(self._extension_backend_list[i])
if not extensions:
raise KeyError('Cannot find an extension with id=%s' % extension_id)
return extensions
......
......@@ -42,8 +42,6 @@ class InspectorBackendList(collections.Sequence):
"""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()):
......@@ -53,12 +51,6 @@ class InspectorBackendList(collections.Sequence):
"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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment