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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 = [] |
| 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 categories = item.split(',') |
| 55 disabled_by_default_categories.append(item) | 55 try: |
| 56 else: | 56 if item.startswith('disabled-by-default'): |
|
dsinclair
2014/11/07 00:05:25
Don't we want to do this check against each item i
r.kasibhatla
2014/11/07 09:58:47
Correct. I was trying to club too many conditions
| |
| 57 record_categories.append(item) | 57 disabled_by_default_categories.append( |
| 58 next(category for category in categories | |
| 59 if category not in disabled_by_default_categories)) | |
| 60 else: | |
| 61 record_categories.append( | |
| 62 next(category for category in categories | |
| 63 if category not in record_categories)) | |
| 64 except StopIteration, e: | |
| 65 pass | |
| 58 | 66 |
| 59 return record_categories, disabled_by_default_categories | 67 return record_categories, disabled_by_default_categories |
| 60 | 68 |
| 61 def StartTracing(self, interval): | 69 def StartTracing(self, interval): |
| 62 self._trace_interval = interval | 70 self._trace_interval = interval |
| 63 self._device.old_interface.SyncLogCat() | 71 self._device.old_interface.SyncLogCat() |
| 64 start_extras = {'categories': ','.join(self._categories)} | 72 start_extras = {'categories': ','.join(self._categories)} |
| 65 if self._ring_buffer: | 73 if self._ring_buffer: |
| 66 start_extras['continuous'] = None | 74 start_extras['continuous'] = None |
| 67 self._device.BroadcastIntent(intent.Intent( | 75 self._device.BroadcastIntent(intent.Intent( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 98 self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) | 106 self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) |
| 99 | 107 |
| 100 def PullTrace(self): | 108 def PullTrace(self): |
| 101 # Wait a bit for the browser to finish writing the trace file. | 109 # Wait a bit for the browser to finish writing the trace file. |
| 102 time.sleep(self._trace_interval / 4 + 1) | 110 time.sleep(self._trace_interval / 4 + 1) |
| 103 | 111 |
| 104 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') | 112 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') |
| 105 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) | 113 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) |
| 106 self._device.PullFile(trace_file, host_file) | 114 self._device.PullFile(trace_file, host_file) |
| 107 return host_file | 115 return host_file |
| OLD | NEW |