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 |