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

Side by Side Diff: tools/profile_chrome/chrome_startup_controller.py

Issue 907443002: Add missing import in chrome_startup_controller.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 os 5 import os
6 import re 6 import re
7 import time 7 import time
8 8
9 from pylib import flag_changer 9 from pylib import flag_changer
10 from pylib.device import intent
10 from pylib.perf import cache_control 11 from pylib.perf import cache_control
11 12
12 from profile_chrome import controllers 13 from profile_chrome import controllers
13 14
14 class ChromeStartupTracingController(controllers.BaseController): 15 class ChromeStartupTracingController(controllers.BaseController):
15 def __init__(self, device, package_info, cold, url): 16 def __init__(self, device, package_info, cold, url):
16 self._device = device 17 self._device = device
17 self._package_info = package_info 18 self._package_info = package_info
18 self._cold = cold 19 self._cold = cold
19 self._logcat_monitor = self._device.GetLogcatMonitor() 20 self._logcat_monitor = self._device.GetLogcatMonitor()
(...skipping 12 matching lines...) Expand all
32 changer.AddFlags(['--trace-startup']) 33 changer.AddFlags(['--trace-startup'])
33 self._device.ForceStop(self._package_info.package) 34 self._device.ForceStop(self._package_info.package)
34 if self._cold: 35 if self._cold:
35 self._device.EnableRoot() 36 self._device.EnableRoot()
36 cache_control.CacheControl(self._device).DropRamCaches() 37 cache_control.CacheControl(self._device).DropRamCaches()
37 self._device.StartActivity( 38 self._device.StartActivity(
38 intent.Intent( 39 intent.Intent(
39 package=self._package_info.package, 40 package=self._package_info.package,
40 activity=self._package_info.activity, 41 activity=self._package_info.activity,
41 data=self._url, 42 data=self._url,
42 extras={'create_new_tab' : True})) 43 extras={'create_new_tab' : True}), blocking=True)
43 44
44 def _TearDownTracing(self): 45 def _TearDownTracing(self):
45 changer = flag_changer.FlagChanger( 46 changer = flag_changer.FlagChanger(
46 self._device, self._package_info.cmdline_file) 47 self._device, self._package_info.cmdline_file)
47 changer.RemoveFlags(['--trace-startup']) 48 changer.RemoveFlags(['--trace-startup'])
48 49
49 def StartTracing(self, interval): 50 def StartTracing(self, interval):
50 self._SetupTracing() 51 self._SetupTracing()
51 self._logcat_monitor.Start() 52 self._logcat_monitor.Start()
52 53
53 def StopTracing(self): 54 def StopTracing(self):
54 try: 55 try:
55 self._trace_file = self._logcat_monitor.WaitFor( 56 self._trace_file = self._logcat_monitor.WaitFor(
56 self._trace_finish_re).group(1) 57 self._trace_finish_re).group(1)
57 finally: 58 finally:
58 self._TearDownTracing() 59 self._TearDownTracing()
59 60
60 def PullTrace(self): 61 def PullTrace(self):
61 # Wait a bit for the browser to finish writing the trace file. 62 # Wait a bit for the browser to finish writing the trace file.
62 time.sleep(3) 63 time.sleep(3)
63 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') 64 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/')
64 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) 65 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file))
65 self._device.PullFile(trace_file, host_file) 66 self._device.PullFile(trace_file, host_file)
66 return host_file 67 return host_file
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698