Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 os | 6 import os |
| 7 import re | 7 import re |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 from profile_chrome import controllers | 10 from profile_chrome import controllers |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 def GetCategories(device, package_info): | 40 def GetCategories(device, package_info): |
| 41 device.BroadcastIntent(intent.Intent( | 41 device.BroadcastIntent(intent.Intent( |
| 42 action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) | 42 action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) |
| 43 try: | 43 try: |
| 44 json_category_list = device.old_interface.WaitForLogMatch( | 44 json_category_list = device.old_interface.WaitForLogMatch( |
| 45 re.compile(r'{"traceCategoriesList(.*)'), None, timeout=5).group(0) | 45 re.compile(r'{"traceCategoriesList(.*)'), None, timeout=5).group(0) |
| 46 except pexpect.TIMEOUT: | 46 except pexpect.TIMEOUT: |
| 47 raise RuntimeError('Performance trace category list marker not found. ' | 47 raise RuntimeError('Performance trace category list marker not found. ' |
| 48 'Is the correct version of the browser running?') | 48 'Is the correct version of the browser running?') |
| 49 | 49 |
| 50 record_categories = [] | 50 record_categories = [] |
|
Sami
2014/11/07 18:58:14
Could you turn both of these lists into sets pleas
r.kasibhatla
2014/11/10 06:42:17
Done.
| |
| 51 disabled_by_default_categories = [] | 51 disabled_by_default_categories = [] |
| 52 json_data = json.loads(json_category_list)['traceCategoriesList'] | 52 json_data = json.loads(json_category_list)['traceCategoriesList'] |
| 53 for item in json_data: | 53 for item in json_data: |
| 54 if item.startswith('disabled-by-default'): | 54 for category in item.split(','): |
| 55 disabled_by_default_categories.append(item) | 55 if category.startswith('disabled-by-default'): |
| 56 else: | 56 if category not in disabled_by_default_categories: |
| 57 record_categories.append(item) | 57 disabled_by_default_categories.append(category) |
| 58 elif category not in record_categories: | |
| 59 record_categories.append(category) | |
| 58 | 60 |
| 59 return record_categories, disabled_by_default_categories | 61 return record_categories, disabled_by_default_categories |
| 60 | 62 |
| 61 def StartTracing(self, interval): | 63 def StartTracing(self, interval): |
| 62 self._trace_interval = interval | 64 self._trace_interval = interval |
| 63 self._device.old_interface.SyncLogCat() | 65 self._device.old_interface.SyncLogCat() |
| 64 start_extras = {'categories': ','.join(self._categories)} | 66 start_extras = {'categories': ','.join(self._categories)} |
| 65 if self._ring_buffer: | 67 if self._ring_buffer: |
| 66 start_extras['continuous'] = None | 68 start_extras['continuous'] = None |
| 67 self._device.BroadcastIntent(intent.Intent( | 69 self._device.BroadcastIntent(intent.Intent( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 98 self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) | 100 self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) |
| 99 | 101 |
| 100 def PullTrace(self): | 102 def PullTrace(self): |
| 101 # Wait a bit for the browser to finish writing the trace file. | 103 # Wait a bit for the browser to finish writing the trace file. |
| 102 time.sleep(self._trace_interval / 4 + 1) | 104 time.sleep(self._trace_interval / 4 + 1) |
| 103 | 105 |
| 104 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') | 106 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') |
| 105 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) | 107 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) |
| 106 self._device.PullFile(trace_file, host_file) | 108 self._device.PullFile(trace_file, host_file) |
| 107 return host_file | 109 return host_file |
| OLD | NEW |