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

Unified Diff: tools/telemetry/telemetry/core/platform/platform_backend.py

Issue 522553002: Move remote platforms creation logic from android_browser_finder to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android_browser_finder_unittest Created 6 years, 3 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
Index: tools/telemetry/telemetry/core/platform/platform_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/platform_backend.py b/tools/telemetry/telemetry/core/platform/platform_backend.py
index 710b8e596d45cffa86725b5d2f5496ca53cf3600..2b9ce567cff586adb84ab33b0579b916d231f1d8 100644
--- a/tools/telemetry/telemetry/core/platform/platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/platform_backend.py
@@ -44,7 +44,19 @@ YOSEMITE = OSVersion('yosemite', 1010)
class PlatformBackend(object):
- def __init__(self):
+
+ def __init__(self, device=None):
+ """ Initalize an instance of PlatformBackend from a device optionally.
+ Call sites need to use SupportsDevice before intialization to check
+ whether this platform backend supports the device.
+ If device is None, this constructor returns the host platform backend
+ which telemetry is running on.
+
+ Args:
+ device: an instance of telemetry.core.platform.device.Device.
+ """
+ if device and not self.SupportsDevice(device):
+ raise ValueError('Unsupported device: %s' % device.name)
self._platform = None
self._running_browser_backends = weakref.WeakSet()
self._tracing_controller_backend = (
@@ -52,6 +64,12 @@ class PlatformBackend(object):
self._profiling_controller_backend = (
profiling_controller_backend.ProfilingControllerBackend(self))
+ @classmethod
+ def SupportsDevice(cls, device):
+ """ Returns whether this platform backend supports intialization from the
+ device. """
+ return False
+
def SetPlatform(self, platform):
assert self._platform == None
self._platform = platform

Powered by Google App Engine
This is Rietveld 408576698