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

Side by Side Diff: tools/telemetry/telemetry/core/chrome/inspector_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import json 4 import json
5 import logging 5 import logging
6 import socket 6 import socket
7 import sys 7 import sys
8 8
9 from telemetry import inspector_console 9 from telemetry.core import util
10 from telemetry import inspector_page 10 from telemetry.core import exceptions
11 from telemetry import inspector_runtime 11 from telemetry.core.chrome import inspector_console
12 from telemetry import inspector_timeline 12 from telemetry.core.chrome import inspector_page
13 from telemetry import png_bitmap 13 from telemetry.core.chrome import inspector_runtime
14 from telemetry import tab_crash_exception 14 from telemetry.core.chrome import inspector_timeline
15 from telemetry import util 15 from telemetry.core.chrome import png_bitmap
16 from telemetry import websocket 16 from telemetry.core.chrome import websocket
17 17
18 class InspectorException(Exception): 18 class InspectorException(Exception):
19 pass 19 pass
20 20
21 class InspectorBackend(object): 21 class InspectorBackend(object):
22 def __init__(self, browser, browser_backend, debugger_url): 22 def __init__(self, browser, browser_backend, debugger_url):
23 assert debugger_url 23 assert debugger_url
24 self._browser = browser 24 self._browser = browser
25 self._browser_backend = browser_backend 25 self._browser_backend = browser_backend
26 self._debugger_url = debugger_url 26 self._debugger_url = debugger_url
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 def DispatchNotifications(self, timeout=10): 188 def DispatchNotifications(self, timeout=10):
189 self._Connect() 189 self._Connect()
190 self._SetTimeout(timeout) 190 self._SetTimeout(timeout)
191 191
192 try: 192 try:
193 data = self._socket.recv() 193 data = self._socket.recv()
194 except (socket.error, websocket.WebSocketException): 194 except (socket.error, websocket.WebSocketException):
195 if self._browser_backend.tab_list_backend.DoesDebuggerUrlExist( 195 if self._browser_backend.tab_list_backend.DoesDebuggerUrlExist(
196 self._debugger_url): 196 self._debugger_url):
197 return 197 return
198 raise tab_crash_exception.TabCrashException() 198 raise exceptions.TabCrashException()
199 199
200 res = json.loads(data) 200 res = json.loads(data)
201 logging.debug('got [%s]', data) 201 logging.debug('got [%s]', data)
202 if 'method' in res: 202 if 'method' in res:
203 self._HandleNotification(res) 203 self._HandleNotification(res)
204 204
205 def _HandleNotification(self, res): 205 def _HandleNotification(self, res):
206 if (res['method'] == 'Inspector.detached' and 206 if (res['method'] == 'Inspector.detached' and
207 res.get('params', {}).get('reason','') == 'replaced_with_devtools'): 207 res.get('params', {}).get('reason','') == 'replaced_with_devtools'):
208 self._WaitForInspectorToGoAwayAndReconnect() 208 self._WaitForInspectorToGoAwayAndReconnect()
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 self.SendAndIgnoreResponse(req) 254 self.SendAndIgnoreResponse(req)
255 255
256 while True: 256 while True:
257 try: 257 try:
258 data = self._socket.recv() 258 data = self._socket.recv()
259 except (socket.error, websocket.WebSocketException): 259 except (socket.error, websocket.WebSocketException):
260 if self._browser_backend.tab_list_backend.DoesDebuggerUrlExist( 260 if self._browser_backend.tab_list_backend.DoesDebuggerUrlExist(
261 self._debugger_url): 261 self._debugger_url):
262 raise util.TimeoutException( 262 raise util.TimeoutException(
263 'Timed out waiting for reply. This is unusual.') 263 'Timed out waiting for reply. This is unusual.')
264 raise tab_crash_exception.TabCrashException() 264 raise exceptions.TabCrashException()
265 265
266 res = json.loads(data) 266 res = json.loads(data)
267 logging.debug('got [%s]', data) 267 logging.debug('got [%s]', data)
268 if 'method' in res: 268 if 'method' in res:
269 self._HandleNotification(res) 269 self._HandleNotification(res)
270 continue 270 continue
271 271
272 if res['id'] != req['id']: 272 if res['id'] != req['id']:
273 logging.debug('Dropped reply: %s', json.dumps(res)) 273 logging.debug('Dropped reply: %s', json.dumps(res))
274 continue 274 continue
(...skipping 14 matching lines...) Expand all
289 OnConsoleNotification, OnConsoleClose) 289 OnConsoleNotification, OnConsoleClose)
290 """ 290 """
291 assert domain_name not in self._domain_handlers 291 assert domain_name not in self._domain_handlers
292 self._domain_handlers[domain_name] = (notification_handler, 292 self._domain_handlers[domain_name] = (notification_handler,
293 will_close_handler) 293 will_close_handler)
294 294
295 def UnregisterDomain(self, domain_name): 295 def UnregisterDomain(self, domain_name):
296 """Unregisters a previously registered domain.""" 296 """Unregisters a previously registered domain."""
297 assert domain_name in self._domain_handlers 297 assert domain_name in self._domain_handlers
298 self._domain_handlers.pop(domain_name) 298 self._domain_handlers.pop(domain_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698