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.
5 from telemetry.core.platform import proc_supporting_platform_backend
6 from telemetry.core.platform import ps_util
7 from telemetry.core.platform.power_monitor import cros_power_monitor
10 class CrosPlatformBackend(
11 proc_supporting_platform_backend.ProcSupportingPlatformBackend):
13 def __init__(self, cri):
14 super(CrosPlatformBackend, self).__init__()
16 self._powermonitor = cros_power_monitor.CrosPowerMonitor(cri)
18 def StartRawDisplayFrameRateMeasurement(self):
19 raise NotImplementedError()
21 def StopRawDisplayFrameRateMeasurement(self):
22 raise NotImplementedError()
24 def GetRawDisplayFrameRateMeasurements(self):
25 raise NotImplementedError()
27 def IsThermallyThrottled(self):
28 raise NotImplementedError()
30 def HasBeenThermallyThrottled(self):
31 raise NotImplementedError()
33 def _RunCommand(self, args):
34 return self._cri.RunCmdOnDevice(args)[0]
36 def _GetFileContents(self, filename):
38 return self._cri.RunCmdOnDevice(['cat', filename])[0]
39 except AssertionError:
42 def GetIOStats(self, pid):
43 # There is no '/proc/<pid>/io' file on CrOS platforms
44 # Returns empty dict as it does in PlatformBackend.
50 def GetOSVersionName(self):
51 return '' # TODO: Implement this.
53 def GetChildPids(self, pid):
54 """Returns a list of child pids of |pid|."""
55 all_process_info = self._cri.ListProcesses()
56 processes = [(curr_pid, curr_ppid, curr_state)
57 for curr_pid, _, curr_ppid, curr_state in all_process_info]
58 return ps_util.GetChildPids(processes, pid)
60 def GetCommandLine(self, pid):
61 procs = self._cri.ListProcesses()
62 return next((proc[1] for proc in procs if proc[0] == pid), None)
64 def CanFlushIndividualFilesFromSystemCache(self):
67 def FlushEntireSystemCache(self):
68 raise NotImplementedError()
70 def FlushSystemCacheForDirectory(self, directory, ignoring=None):
71 raise NotImplementedError()
73 def CanMonitorPower(self):
74 return self._powermonitor.CanMonitorPower()
76 def StartMonitoringPower(self, browser):
77 self._powermonitor.StartMonitoringPower(browser)
79 def StopMonitoringPower(self):
80 return self._powermonitor.StopMonitoringPower()