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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/resource_prefetch_predictor/prefetch_predictor_common.py
diff --git a/tools/resource_prefetch_predictor/prefetch_predictor_common.py b/tools/resource_prefetch_predictor/prefetch_predictor_common.py
new file mode 100644
index 0000000000000000000000000000000000000000..aeed9388a63597fb265c2327dc2f5fa250812696
--- /dev/null
+++ b/tools/resource_prefetch_predictor/prefetch_predictor_common.py
@@ -0,0 +1,48 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Common utils for the speculative resource prefetch evaluation."""
+
+import argparse
pasko 2016/11/30 12:53:46 not necessary?
Benoit L 2016/11/30 15:25:50 Done.
+import logging
+import os
+import sys
+
+_SRC_PATH = os.path.abspath(os.path.join(
+ os.path.dirname(__file__), os.pardir, os.pardir))
+
+sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil'))
+from devil.android import device_utils
+
+sys.path.append(os.path.join(_SRC_PATH, 'tools', 'android', 'loading'))
+import controller
+from options import OPTIONS
+
+
+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.
+ """Returns a device matching |device_id| or the first one if None, or None."""
+ devices = device_utils.DeviceUtils.HealthyDevices()
+ if device_id is None:
+ return devices[0]
+ 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.
+ if not matching_devices:
+ return None
+ return matching_devices[0]
+
+
+def Setup(device, additional_flags=None):
+ """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.
+ if not device.HasRoot():
+ device.EnableRoot()
+ chrome_controller = controller.RemoteChromeController(device)
+ device.ForceStop(OPTIONS.ChromePackage().package)
+ if additional_flags is not None:
+ chrome_controller.AddChromeArguments(additional_flags)
+ chrome_controller.ResetBrowserState()
+ return chrome_controller
+
+
+def DatabaseDevicePath():
+ return ('/data/user/0/%s/app_chrome/Default/Network Action Predictor' %
+ OPTIONS.ChromePackage().package)

Powered by Google App Engine
This is Rietveld 408576698