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

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

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 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
« no previous file with comments | « tools/telemetry/telemetry/extension_dict.py ('k') | tools/telemetry/telemetry/extension_page.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/extension_dict_backend.py
diff --git a/tools/telemetry/telemetry/extension_dict_backend.py b/tools/telemetry/telemetry/extension_dict_backend.py
deleted file mode 100644
index b9167933a628df4df76b381ae58a5564074f982d..0000000000000000000000000000000000000000
--- a/tools/telemetry/telemetry/extension_dict_backend.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright (c) 2012 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 httplib
-import json
-import re
-import socket
-import urllib2
-import weakref
-
-from telemetry import browser_gone_exception
-from telemetry import extension_page
-from telemetry import inspector_backend
-
-class ExtensionNotFoundException(Exception):
- pass
-
-class ExtensionDictBackend(object):
- def __init__(self, browser_backend):
- self._browser_backend = browser_backend
- # Maps extension ids to ExtensionPage objects.
- self._extension_dict = weakref.WeakValueDictionary()
-
- def __getitem__(self, extension_id):
- extension_object = self._extension_dict.get(extension_id)
- if not extension_object:
- extension_object = self._CreateExtensionObject(extension_id)
- assert extension_object
- self._extension_dict[extension_id] = extension_object
- return extension_object
-
- def __contains__(self, extension_id):
- return extension_id in self._GetExtensionIds()
-
- @staticmethod
- def _ExtractExtensionId(url):
- m = re.match(r"(chrome-extension://)([^/]+)", url)
- assert m
- return m.group(2)
-
- @staticmethod
- def _GetExtensionId(extension_info):
- if 'url' not in extension_info:
- return None
- return ExtensionDictBackend._ExtractExtensionId(extension_info['url'])
-
- def _CreateExtensionObject(self, extension_id):
- extension_info = self._FindExtensionInfo(extension_id)
- if not extension_info or not 'webSocketDebuggerUrl' in extension_info:
- raise ExtensionNotFoundException()
- return extension_page.ExtensionPage(
- self._CreateInspectorBackendForDebuggerUrl(
- extension_info['webSocketDebuggerUrl']))
-
- def _CreateInspectorBackendForDebuggerUrl(self, debugger_url):
- return inspector_backend.InspectorBackend(self._browser_backend.browser,
- self._browser_backend,
- debugger_url)
-
- def _FindExtensionInfo(self, extension_id):
- for extension_info in self._GetExtensionInfoList():
- if self._GetExtensionId(extension_info) == extension_id:
- return extension_info
- return None
-
- def _GetExtensionInfoList(self, timeout=None):
- try:
- data = self._browser_backend.Request('', timeout=timeout)
- return self._FilterExtensions(json.loads(data))
- except (socket.error, httplib.BadStatusLine, urllib2.URLError):
- if not self._browser_backend.IsBrowserRunning():
- raise browser_gone_exception.BrowserGoneException()
- raise browser_gone_exception.BrowserConnectionGoneException()
-
- def _FilterExtensions(self, all_pages):
- return [page_info for page_info in all_pages
- if page_info['url'].startswith('chrome-extension://')]
-
- def _GetExtensionIds(self):
- return map(self._GetExtensionId, self._GetExtensionInfoList())
« no previous file with comments | « tools/telemetry/telemetry/extension_dict.py ('k') | tools/telemetry/telemetry/extension_page.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698