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

Side by Side Diff: tools/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend.py

Issue 1338423007: [Telemetry] Platform-level tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fix Created 5 years, 2 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 4
5 import json 5 import json
6 import socket 6 import socket
7 import sys 7 import sys
8 import time 8 import time
9 9
10 from telemetry import decorators 10 from telemetry import decorators
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 self._data += result['data'] 90 self._data += result['data']
91 if not result.get('eof', False): 91 if not result.get('eof', False):
92 self._ReadChunkFromStream() 92 self._ReadChunkFromStream()
93 return 93 return
94 req = {'method': 'IO.close', 'params': {'handle': self._handle}} 94 req = {'method': 'IO.close', 'params': {'handle': self._handle}}
95 self._inspector_websocket.SendAndIgnoreResponse(req) 95 self._inspector_websocket.SendAndIgnoreResponse(req)
96 self._callback(self._data) 96 self._callback(self._data)
97 97
98 98
99 class TracingBackend(object): 99 class TracingBackend(object):
100 def __init__(self, devtools_port): 100 def __init__(self, devtools_port, is_tracing_running=False):
101 self._inspector_websocket = inspector_websocket.InspectorWebsocket() 101 self._inspector_websocket = inspector_websocket.InspectorWebsocket()
102 self._inspector_websocket.RegisterDomain( 102 self._inspector_websocket.RegisterDomain(
103 'Tracing', self._NotificationHandler) 103 'Tracing', self._NotificationHandler)
104 104
105 self._inspector_websocket.Connect( 105 self._inspector_websocket.Connect(
106 'ws://127.0.0.1:%i/devtools/browser' % devtools_port) 106 'ws://127.0.0.1:%i/devtools/browser' % devtools_port)
107 self._trace_events = [] 107 self._trace_events = []
108 self._is_tracing_running = False 108 self._is_tracing_running = is_tracing_running
109 self._has_received_all_tracing_data = False 109 self._has_received_all_tracing_data = False
110 110
111 @property 111 @property
112 def is_tracing_running(self): 112 def is_tracing_running(self):
113 return self._is_tracing_running 113 return self._is_tracing_running
114 114
115 def StartTracing(self, trace_options, custom_categories=None, timeout=10): 115 def StartTracing(self, trace_options, custom_categories=None, timeout=10):
116 """When first called, starts tracing, and returns True. 116 """When first called, starts tracing, and returns True.
117 117
118 If called during tracing, tracing is unchanged, and it returns False. 118 If called during tracing, tracing is unchanged, and it returns False.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 self._has_received_all_tracing_data = True 247 self._has_received_all_tracing_data = True
248 248
249 def Close(self): 249 def Close(self):
250 self._inspector_websocket.Disconnect() 250 self._inspector_websocket.Disconnect()
251 251
252 @decorators.Cache 252 @decorators.Cache
253 def IsTracingSupported(self): 253 def IsTracingSupported(self):
254 req = {'method': 'Tracing.hasCompleted'} 254 req = {'method': 'Tracing.hasCompleted'}
255 res = self._inspector_websocket.SyncRequest(req) 255 res = self._inspector_websocket.SyncRequest(req)
256 return not res.get('response') 256 return not res.get('response')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698