1 # Copyright 2013 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.
7 from telemetry.core.platform import tracing_controller_backend
10 # pylint: disable=W0613
12 # pylint: disable=W0212
14 def __new__(cls, friendly_name, sortable_name, *args, **kwargs):
15 version = str.__new__(cls, friendly_name)
16 version._sortable_name = sortable_name
19 def __lt__(self, other):
20 return self._sortable_name < other._sortable_name
22 def __gt__(self, other):
23 return self._sortable_name > other._sortable_name
25 def __le__(self, other):
26 return self._sortable_name <= other._sortable_name
28 def __ge__(self, other):
29 return self._sortable_name >= other._sortable_name
32 XP = OSVersion('xp', 5.1)
33 VISTA = OSVersion('vista', 6.0)
34 WIN7 = OSVersion('win7', 6.1)
35 WIN8 = OSVersion('win8', 6.2)
37 LEOPARD = OSVersion('leopard', 10.5)
38 SNOWLEOPARD = OSVersion('snowleopard', 10.6)
39 LION = OSVersion('lion', 10.7)
40 MOUNTAINLION = OSVersion('mountainlion', 10.8)
41 MAVERICKS = OSVersion('mavericks', 10.9)
44 class PlatformBackend(object):
47 self._running_browser_backends = weakref.WeakSet()
48 self._tracing_controller_backend = \
49 tracing_controller_backend.TracingControllerBackend(self)
51 def SetPlatform(self, platform):
52 assert self._platform == None
53 self._platform = platform
60 def running_browser_backends(self):
61 return list(self._running_browser_backends)
64 def tracing_controller_backend(self):
65 return self._tracing_controller_backend
67 def DidCreateBrowser(self, browser, browser_backend):
68 self.SetFullPerformanceModeEnabled(True)
70 def DidStartBrowser(self, browser, browser_backend):
71 assert browser not in self._running_browser_backends
72 self._running_browser_backends.add(browser_backend)
73 self._tracing_controller_backend.DidStartBrowser(
74 browser, browser_backend)
76 def WillCloseBrowser(self, browser, browser_backend):
77 self._tracing_controller_backend.WillCloseBrowser(
78 browser, browser_backend)
80 is_last_browser = len(self._running_browser_backends) == 1
82 self.SetFullPerformanceModeEnabled(False)
84 self._running_browser_backends.remove(browser_backend)
86 def GetBackendForBrowser(self, browser):
87 matches = [x for x in self._running_browser_backends
88 if x.browser == browser]
90 raise Exception('No browser found')
91 assert len(matches) == 1
94 def IsRawDisplayFrameRateSupported(self):
97 def StartRawDisplayFrameRateMeasurement(self):
98 raise NotImplementedError()
100 def StopRawDisplayFrameRateMeasurement(self):
101 raise NotImplementedError()
103 def GetRawDisplayFrameRateMeasurements(self):
104 raise NotImplementedError()
106 def SetFullPerformanceModeEnabled(self, enabled):
109 def CanMonitorThermalThrottling(self):
112 def IsThermallyThrottled(self):
113 raise NotImplementedError()
115 def HasBeenThermallyThrottled(self):
116 raise NotImplementedError()
118 def GetSystemCommitCharge(self):
119 raise NotImplementedError()
121 def GetSystemTotalPhysicalMemory(self):
122 raise NotImplementedError()
124 def GetCpuStats(self, pid):
127 def GetCpuTimestamp(self):
130 def PurgeUnpinnedMemory(self):
133 def GetMemoryStats(self, pid):
136 def GetIOStats(self, pid):
139 def GetChildPids(self, pid):
140 raise NotImplementedError()
142 def GetCommandLine(self, pid):
143 raise NotImplementedError()
146 raise NotImplementedError()
148 def GetOSVersionName(self):
149 raise NotImplementedError()
151 def CanFlushIndividualFilesFromSystemCache(self):
152 raise NotImplementedError()
154 def FlushEntireSystemCache(self):
155 raise NotImplementedError()
157 def FlushSystemCacheForDirectory(self, directory, ignoring=None):
158 raise NotImplementedError()
160 def FlushDnsCache(self):
163 def LaunchApplication(
164 self, application, parameters=None, elevate_privilege=False):
165 raise NotImplementedError()
167 def IsApplicationRunning(self, application):
168 raise NotImplementedError()
170 def CanLaunchApplication(self, application):
173 def InstallApplication(self, application):
174 raise NotImplementedError()
176 def CanCaptureVideo(self):
179 def StartVideoCapture(self, min_bitrate_mbps):
180 raise NotImplementedError()
183 def is_video_capture_running(self):
186 def StopVideoCapture(self):
187 raise NotImplementedError()
189 def CanMonitorPower(self):
192 def CanMeasurePerApplicationPower(self):
195 def StartMonitoringPower(self, browser):
196 raise NotImplementedError()
198 def StopMonitoringPower(self):
199 raise NotImplementedError()