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

Unified Diff: build/android/adb_profile_chrome.py

Issue 221823011: [Android] Change object types from AndroidCommands to DeviceUtils in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/adb_kill_content_shell ('k') | build/android/adb_reverse_forwarder.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/adb_profile_chrome.py
diff --git a/build/android/adb_profile_chrome.py b/build/android/adb_profile_chrome.py
index a219bfe2cecdda2978daaf80349da4ca17262862..ae69cbe772d253e1938abe1c363a29a851dbbd79 100755
--- a/build/android/adb_profile_chrome.py
+++ b/build/android/adb_profile_chrome.py
@@ -22,6 +22,7 @@ from pylib import android_commands
from pylib import cmd_helper
from pylib import constants
from pylib import pexpect
+from pylib.device import device_utils
_TRACE_VIEWER_ROOT = os.path.join(constants.DIR_SOURCE_ROOT,
'third_party', 'trace-viewer')
@@ -36,8 +37,8 @@ def _GetTraceTimestamp():
class ChromeTracingController(object):
- def __init__(self, adb, package_info, categories, ring_buffer):
- self._adb = adb
+ def __init__(self, device, package_info, categories, ring_buffer):
+ self._device = device
self._package_info = package_info
self._categories = categories
self._ring_buffer = ring_buffer
@@ -47,17 +48,18 @@ class ChromeTracingController(object):
re.compile(r'Logging performance trace to file: (.*)')
self._trace_finish_re = \
re.compile(r'Profiler finished[.] Results are in (.*)[.]')
- self._adb.StartMonitoringLogcat(clear=False)
+ self._device.old_interface.StartMonitoringLogcat(clear=False)
def __str__(self):
return 'chrome trace'
def StartTracing(self, interval):
self._trace_interval = interval
- self._adb.SyncLogCat()
- self._adb.BroadcastIntent(self._package_info.package, 'GPU_PROFILER_START',
- '-e categories "%s"' % ','.join(self._categories),
- '-e continuous' if self._ring_buffer else '')
+ self._device.old_interface.SyncLogCat()
+ self._device.old_interface.BroadcastIntent(
+ self._package_info.package, 'GPU_PROFILER_START',
+ '-e categories "%s"' % ','.join(self._categories),
+ '-e continuous' if self._ring_buffer else '')
# Chrome logs two different messages related to tracing:
#
# 1. "Logging performance trace to file [...]"
@@ -66,9 +68,8 @@ class ChromeTracingController(object):
# The first one is printed when tracing starts and the second one indicates
# that the trace file is ready to be pulled.
try:
- self._trace_file = self._adb.WaitForLogMatch(self._trace_start_re,
- None,
- timeout=5).group(1)
+ self._trace_file = self._device.old_interface.WaitForLogMatch(
+ self._trace_start_re, None, timeout=5).group(1)
except pexpect.TIMEOUT:
raise RuntimeError('Trace start marker not found. Is the correct version '
'of the browser running?')
@@ -76,8 +77,10 @@ class ChromeTracingController(object):
def StopTracing(self):
if not self._trace_file:
return
- self._adb.BroadcastIntent(self._package_info.package, 'GPU_PROFILER_STOP')
- self._adb.WaitForLogMatch(self._trace_finish_re, None, timeout=120)
+ self._device.old_interface.BroadcastIntent(self._package_info.package,
+ 'GPU_PROFILER_STOP')
+ self._device.old_interface.WaitForLogMatch(self._trace_finish_re, None,
+ timeout=120)
def PullTrace(self):
# Wait a bit for the browser to finish writing the trace file.
@@ -85,7 +88,7 @@ class ChromeTracingController(object):
trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/')
host_file = os.path.join(os.path.curdir, os.path.basename(trace_file))
- self._adb.PullFileFromDevice(trace_file, host_file)
+ self._device.old_interface.PullFileFromDevice(trace_file, host_file)
return host_file
@@ -101,8 +104,8 @@ _SYSTRACE_INTERVAL = 15
class SystraceController(object):
- def __init__(self, adb, categories, ring_buffer):
- self._adb = adb
+ def __init__(self, device, categories, ring_buffer):
+ self._device = device
self._categories = categories
self._ring_buffer = ring_buffer
self._done = threading.Event()
@@ -113,8 +116,8 @@ class SystraceController(object):
return 'systrace'
@staticmethod
- def GetCategories(adb):
- return adb.RunShellCommand('atrace --list_categories')
+ def GetCategories(device):
+ return device.old_interface.RunShellCommand('atrace --list_categories')
def StartTracing(self, _):
self._thread = threading.Thread(target=self._CollectData)
@@ -133,10 +136,12 @@ class SystraceController(object):
return output_name
def _RunATraceCommand(self, command):
+ # TODO(jbudorick) can this be made work with DeviceUtils?
# We use a separate interface to adb because the one from AndroidCommands
# isn't re-entrant.
- device = ['-s', self._adb.GetDevice()] if self._adb.GetDevice() else []
- cmd = ['adb'] + device + ['shell', 'atrace', '--%s' % command] + \
+ device_param = (['-s', self._device.old_interface.GetDevice()]
+ if self._device.old_interface.GetDevice() else [])
+ cmd = ['adb'] + device_param + ['shell', 'atrace', '--%s' % command] + \
_SYSTRACE_OPTIONS + self._categories
return cmd_helper.GetCmdOutput(cmd)
@@ -375,9 +380,13 @@ When in doubt, just try out --trace-frame-viewer.
if options.verbose:
logging.getLogger().setLevel(logging.DEBUG)
- adb = android_commands.AndroidCommands()
+ devices = android_commands.GetAttachedDevices()
+ if len(devices) != 1:
+ parser.error('Exactly 1 device much be attached.')
+ device = device_utils.DeviceUtils(devices[0])
+
if options.systrace_categories in ['list', 'help']:
- _PrintMessage('\n'.join(SystraceController.GetCategories(adb)))
+ _PrintMessage('\n'.join(SystraceController.GetCategories(device)))
return 0
if not options.time and not options.continuous:
@@ -394,12 +403,12 @@ When in doubt, just try out --trace-frame-viewer.
controllers = []
if chrome_categories:
- controllers.append(ChromeTracingController(adb,
+ controllers.append(ChromeTracingController(device,
package_info,
chrome_categories,
options.ring_buffer))
if systrace_categories:
- controllers.append(SystraceController(adb,
+ controllers.append(SystraceController(device,
systrace_categories,
options.ring_buffer))
« no previous file with comments | « build/android/adb_kill_content_shell ('k') | build/android/adb_reverse_forwarder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698