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

Side by Side Diff: tools/resource_prefetch_predictor/prefetch_predictor_common.py

Issue 2508933002: tools: Local tests for the speculative prefetch predictor. (Closed)
Patch Set: Rebase. Created 4 years 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
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Common utils for the speculative resource prefetch evaluation."""
6
7 import argparse
pasko 2016/11/30 12:53:46 not necessary?
Benoit L 2016/11/30 15:25:50 Done.
8 import logging
9 import os
10 import sys
11
12 _SRC_PATH = os.path.abspath(os.path.join(
13 os.path.dirname(__file__), os.pardir, os.pardir))
14
15 sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil'))
16 from devil.android import device_utils
17
18 sys.path.append(os.path.join(_SRC_PATH, 'tools', 'android', 'loading'))
19 import controller
20 from options import OPTIONS
21
22
23 def FindDevice(device_id):
pasko 2016/11/30 12:53:46 can we use device_setup.GetDeviceFromSerial()?
Benoit L 2016/11/30 15:25:50 Thanks! Done.
24 """Returns a device matching |device_id| or the first one if None, or None."""
25 devices = device_utils.DeviceUtils.HealthyDevices()
26 if device_id is None:
27 return devices[0]
28 matching_devices = [d for d in devices if str(d) == device_id]
pasko 2016/11/30 12:53:46 nit: constructing the list to only get the first e
Benoit L 2016/11/30 15:25:50 Acknowledged.
29 if not matching_devices:
30 return None
31 return matching_devices[0]
32
33
34 def Setup(device, additional_flags=None):
35 """Sets up a device and returns an instance of RemoteChromeController."""
pasko 2016/11/30 12:53:46 should document |additional_flags| and the class f
Benoit L 2016/11/30 15:25:50 Done.
36 if not device.HasRoot():
37 device.EnableRoot()
38 chrome_controller = controller.RemoteChromeController(device)
39 device.ForceStop(OPTIONS.ChromePackage().package)
40 if additional_flags is not None:
41 chrome_controller.AddChromeArguments(additional_flags)
42 chrome_controller.ResetBrowserState()
43 return chrome_controller
44
45
46 def DatabaseDevicePath():
47 return ('/data/user/0/%s/app_chrome/Default/Network Action Predictor' %
48 OPTIONS.ChromePackage().package)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698