Index: build/android/adb_profile_chrome.py |
diff --git a/build/android/adb_profile_chrome.py b/build/android/adb_profile_chrome.py |
index 37f250c19a2b4b9c38c0e2cb1f87cf96b4406d13..ae69ced1b55a707d032a36e5b9515da8509cab43 100755 |
--- a/build/android/adb_profile_chrome.py |
+++ b/build/android/adb_profile_chrome.py |
@@ -5,6 +5,7 @@ |
# found in the LICENSE file. |
import gzip |
+import json |
import logging |
import optparse |
import os |
@@ -53,6 +54,38 @@ class ChromeTracingController(object): |
def __str__(self): |
return 'chrome trace' |
+ @staticmethod |
+ def GetCategories(device, package_info): |
+ device.old_interface.BroadcastIntent( |
+ package_info.package, 'GPU_PROFILER_LIST_CATEGORY') |
+ try: |
+ json_category_list = device.old_interface.WaitForLogMatch( |
+ re.compile(r'{"traceCategoriesList(.*)'), None, timeout=5).group(0) |
+ |
+ record_categories = [] |
+ disabled_by_default_categories = [] |
+ try: |
+ json_data = json.loads(json_category_list)['traceCategoriesList'] |
+ for item in json_data: |
+ if item.startswith('disabled-by-default'): |
+ disabled_by_default_categories.append(item) |
+ else: |
+ record_categories.append(item) |
+ except (ValueError, KeyError, TypeError): |
+ logging.error('JSON format error') |
Sami
2014/05/06 14:29:51
I'd prefer just passing these exceptions through s
r.kasibhatla
2014/05/06 15:22:29
Done.
|
+ |
+ _PrintMessage('Record Categories:') |
Sami
2014/05/06 14:29:51
Instead of printing the results here, could you re
r.kasibhatla
2014/05/06 15:22:29
In the original patch, I was returning the tuple,
|
+ _PrintMessage('\n'.join(str('\t%s' % item) \ |
Sami
2014/05/06 14:29:51
Nit: "str" is unneeded here.
r.kasibhatla
2014/05/06 15:22:29
Done.
|
+ for item in sorted(record_categories))) |
+ |
+ _PrintMessage('\nDisabled by Default Categories:') |
+ _PrintMessage('\n'.join(str('\t%s' % item) \ |
Sami
2014/05/06 14:29:51
Ditto.
r.kasibhatla
2014/05/06 15:22:29
Done.
|
+ for item in sorted(disabled_by_default_categories))) |
+ |
+ except pexpect.TIMEOUT: |
Sami
2014/05/06 14:29:51
Please move this try/except block immediately arou
r.kasibhatla
2014/05/06 15:22:29
Done.
|
+ raise RuntimeError('Performance trace category list marker not found. ' |
+ 'Is the correct version of the browser running?') |
+ |
def StartTracing(self, interval): |
self._trace_interval = interval |
self._device.old_interface.SyncLogCat() |
@@ -324,7 +357,8 @@ def main(): |
'categories with comma-delimited wildcards, ' |
'e.g., "*", "cat1*,-cat1a". Omit this option to trace ' |
'Chrome\'s default categories. Chrome tracing can be ' |
- 'disabled with "--categories=\'\'".', |
+ 'disabled with "--categories=\'\'". Use "list" to see ' |
+ 'the available categories.', |
metavar='CHROME_CATEGORIES', dest='chrome_categories', |
default=_DEFAULT_CHROME_CATEGORIES) |
categories.add_option('-s', '--systrace', help='Capture a systrace with the ' |
@@ -383,6 +417,12 @@ When in doubt, just try out --trace-frame-viewer. |
if len(devices) != 1: |
parser.error('Exactly 1 device much be attached.') |
device = device_utils.DeviceUtils(devices[0]) |
+ package_info = _GetSupportedBrowsers()[options.browser] |
+ |
+ if options.chrome_categories in ['list', 'help']: |
+ _PrintMessage('Collecting data...', '\r') |
Sami
2014/05/06 14:29:51
Nit: please use eol='' to match the other function
r.kasibhatla
2014/05/06 15:22:29
Done.
|
+ ChromeTracingController.GetCategories(device, package_info) |
+ return 0 |
if options.systrace_categories in ['list', 'help']: |
_PrintMessage('\n'.join(SystraceController.GetCategories(device))) |
@@ -394,7 +434,6 @@ When in doubt, just try out --trace-frame-viewer. |
chrome_categories = _ComputeChromeCategories(options) |
systrace_categories = _ComputeSystraceCategories(options) |
- package_info = _GetSupportedBrowsers()[options.browser] |
if chrome_categories and 'webview' in systrace_categories: |
logging.warning('Using the "webview" category in systrace together with ' |