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

Side by Side Diff: tools/android/loading/devtools_monitor.py

Issue 2672803002: [Telemetry refactor] Migrate clients to new JavaScript API (batch 3) (Closed)
Patch Set: add comment on tools/android Created 3 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
OLDNEW
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2016 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 """Library handling DevTools websocket interaction. 5 """Library handling DevTools websocket interaction.
6 """ 6 """
7 7
8 import datetime 8 import datetime
9 import httplib 9 import httplib
10 import json 10 import json
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 def ExecuteJavaScript(self, expression): 282 def ExecuteJavaScript(self, expression):
283 """Run JavaScript expression. 283 """Run JavaScript expression.
284 284
285 Args: 285 Args:
286 expression: JavaScript expression to run. 286 expression: JavaScript expression to run.
287 287
288 Returns: 288 Returns:
289 The return value from the JavaScript expression. 289 The return value from the JavaScript expression.
290 """ 290 """
291 # Note: Clients may be tempted to do naive string interpolation to inject
292 # Python values into the JavaScript expression, which could lead to syntax
293 # errors during evaluation (e.g. injecting strings with special characters).
294 # If this becomes an issue, consider extending the interface of this method
295 # as in: https://github.com/catapult-project/catapult/issues/3028
291 response = self.SyncRequest('Runtime.evaluate', { 296 response = self.SyncRequest('Runtime.evaluate', {
292 'expression': expression, 297 'expression': expression,
293 'returnByValue': True}) 298 'returnByValue': True})
294 if 'error' in response: 299 if 'error' in response:
295 raise Exception(response['error']['message']) 300 raise Exception(response['error']['message'])
296 if 'wasThrown' in response['result'] and response['result']['wasThrown']: 301 if 'wasThrown' in response['result'] and response['result']['wasThrown']:
297 raise Exception(response['error']['result']['description']) 302 raise Exception(response['error']['result']['description'])
298 if response['result']['result']['type'] == 'undefined': 303 if response['result']['result']['type'] == 'undefined':
299 return None 304 return None
300 return response['result']['result']['value'] 305 return response['result']['result']['value']
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 json_data: (dict) Parsed from a JSON file using the json module. 485 json_data: (dict) Parsed from a JSON file using the json module.
481 486
482 Returns: 487 Returns:
483 a Track instance. 488 a Track instance.
484 """ 489 """
485 # There is no sensible way to deserialize this abstract class, but 490 # There is no sensible way to deserialize this abstract class, but
486 # subclasses are not required to define a deserialization method. For 491 # subclasses are not required to define a deserialization method. For
487 # example, for testing we have a FakeRequestTrack which is never 492 # example, for testing we have a FakeRequestTrack which is never
488 # deserialized; instead fake instances are deserialized as RequestTracks. 493 # deserialized; instead fake instances are deserialized as RequestTracks.
489 assert False 494 assert False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698