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

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

Issue 436873003: Make telemetry platform a singleton (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase_again Created 6 years, 4 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
« no previous file with comments | « tools/telemetry/telemetry/core/browser.py ('k') | tools/telemetry/telemetry/core/platform/factory.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/__init__.py
diff --git a/tools/telemetry/telemetry/core/platform/__init__.py b/tools/telemetry/telemetry/core/platform/__init__.py
index 91c9747adba6e21dde1b1ad01499e04422795fa7..a13cbc279de200ee51938e94b511a4c68f231888 100644
--- a/tools/telemetry/telemetry/core/platform/__init__.py
+++ b/tools/telemetry/telemetry/core/platform/__init__.py
@@ -2,11 +2,35 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from telemetry.core.platform import factory
+import sys
+
+
+_host_platform = None
+
+
+def _InitHostPlatformIfNeeded():
+ global _host_platform
+ if _host_platform:
+ return
+
+ if sys.platform.startswith('linux'):
+ from telemetry.core.platform import linux_platform_backend
+ backend = linux_platform_backend.LinuxPlatformBackend()
+ elif sys.platform == 'darwin':
+ from telemetry.core.platform import mac_platform_backend
+ backend = mac_platform_backend.MacPlatformBackend()
+ elif sys.platform == 'win32':
+ from telemetry.core.platform import win_platform_backend
+ backend = win_platform_backend.WinPlatformBackend()
+ else:
+ raise NotImplementedError()
+
+ _host_platform = Platform(backend)
def GetHostPlatform():
- return Platform(factory.GetPlatformBackendForCurrentOS())
+ _InitHostPlatformIfNeeded()
+ return _host_platform
class Platform(object):
@@ -18,6 +42,7 @@ class Platform(object):
"""
def __init__(self, platform_backend):
self._platform_backend = platform_backend
+ self._platform_backend.SetPlatform(self)
def IsRawDisplayFrameRateSupported(self):
"""Platforms may be able to collect GL surface stats."""
« no previous file with comments | « tools/telemetry/telemetry/core/browser.py ('k') | tools/telemetry/telemetry/core/platform/factory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698