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

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

Issue 1707793002: sandwich: Refactor to use more existing code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses benoit's comments Created 4 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
« no previous file with comments | « tools/android/loading/run_sandwich.py ('k') | tools/android/loading/tracing.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /usr/bin/python 1 #! /usr/bin/python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Loading trace recorder.""" 6 """Loading trace recorder."""
7 7
8 import argparse 8 import argparse
9 import datetime 9 import datetime
10 import json 10 import json
(...skipping 12 matching lines...) Expand all
23 import devil_chromium 23 import devil_chromium
24 24
25 import device_setup 25 import device_setup
26 import devtools_monitor 26 import devtools_monitor
27 import loading_trace 27 import loading_trace
28 import page_track 28 import page_track
29 import request_track 29 import request_track
30 import tracing 30 import tracing
31 31
32 32
33 def MonitorUrl(connection, url, clear_cache=False): 33 def MonitorUrl(connection, url, clear_cache=False,
34 categories=tracing.DEFAULT_CATEGORIES):
34 """Monitor a URL via a trace recorder. 35 """Monitor a URL via a trace recorder.
35 36
36 Args: 37 Args:
37 connection: A device_monitor.DevToolsConnection instance. 38 connection: A device_monitor.DevToolsConnection instance.
38 url: url to navigate to as string. 39 url: url to navigate to as string.
39 clear_cache: boolean indicating if cache should be cleared before loading. 40 clear_cache: boolean indicating if cache should be cleared before loading.
41 categories: List of tracing event categories to record.
40 42
41 Returns: 43 Returns:
42 loading_trace.LoadingTrace. 44 loading_trace.LoadingTrace.
43 """ 45 """
44 page = page_track.PageTrack(connection) 46 page = page_track.PageTrack(connection)
45 request = request_track.RequestTrack(connection) 47 request = request_track.RequestTrack(connection)
46 trace = tracing.TracingTrack(connection) 48 trace = tracing.TracingTrack(connection, categories=categories)
47 connection.SetUpMonitoring() 49 connection.SetUpMonitoring()
48 if clear_cache: 50 if clear_cache:
49 connection.ClearCache() 51 connection.ClearCache()
50 connection.SendAndIgnoreResponse('Page.navigate', {'url': url}) 52 connection.SendAndIgnoreResponse('Page.navigate', {'url': url})
51 connection.StartMonitoring() 53 connection.StartMonitoring()
52 metadata = {'date': datetime.datetime.utcnow().isoformat(), 54 metadata = {'date': datetime.datetime.utcnow().isoformat(),
53 'seconds_since_epoch': time.time()} 55 'seconds_since_epoch': time.time()}
54 return loading_trace.LoadingTrace(url, metadata, page, request, trace) 56 return loading_trace.LoadingTrace(url, metadata, page, request, trace)
55 57
56 def RecordAndDumpTrace(device, url, output_filename): 58 def RecordAndDumpTrace(device, url, output_filename):
(...skipping 13 matching lines...) Expand all
70 args = parser.parse_args() 72 args = parser.parse_args()
71 url = args.url 73 url = args.url
72 if not url.startswith('http'): 74 if not url.startswith('http'):
73 url = 'http://' + url 75 url = 'http://' + url
74 device = device_utils.DeviceUtils.HealthyDevices()[0] 76 device = device_utils.DeviceUtils.HealthyDevices()[0]
75 RecordAndDumpTrace(device, url, args.output) 77 RecordAndDumpTrace(device, url, args.output)
76 78
77 79
78 if __name__ == '__main__': 80 if __name__ == '__main__':
79 main() 81 main()
OLDNEW
« no previous file with comments | « tools/android/loading/run_sandwich.py ('k') | tools/android/loading/tracing.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698