1 # Copyright (c) 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
9 class CrosPlatformBackend(
10 proc_supporting_platform_backend.ProcSupportingPlatformBackend):
12 def __init__(self, cri):
13 super(CrosPlatformBackend, self).__init__()
16 def StartRawDisplayFrameRateMeasurement(self):
17 raise NotImplementedError()
19 def StopRawDisplayFrameRateMeasurement(self):
20 raise NotImplementedError()
22 def GetRawDisplayFrameRateMeasurements(self):
23 raise NotImplementedError()
25 def IsThermallyThrottled(self):
26 raise NotImplementedError()
28 def HasBeenThermallyThrottled(self):
29 raise NotImplementedError()
31 def _RunCommand(self, args):
32 return self._cri.RunCmdOnDevice(args)[0]
34 def _GetFileContents(self, filename):
36 return self._cri.RunCmdOnDevice(['cat', filename])[0]
37 except AssertionError:
40 def GetIOStats(self, pid):
41 # There is no '/proc/<pid>/io' file on CrOS platforms
42 # Returns empty dict as it does in PlatformBackend.
48 def GetOSVersionName(self):
49 return '' # TODO: Implement this.
51 def GetChildPids(self, pid):
52 """Returns a list of child pids of |pid|."""
53 all_process_info = self._cri.ListProcesses()
54 processes = [(curr_pid, curr_ppid, curr_state)
55 for curr_pid, _, curr_ppid, curr_state in all_process_info]
56 return ps_util.GetChildPids(processes, pid)
58 def GetCommandLine(self, pid):
59 procs = self._cri.ListProcesses()
60 return next((proc[1] for proc in procs if proc[0] == pid), None)
62 def CanFlushIndividualFilesFromSystemCache(self):
65 def FlushEntireSystemCache(self):
66 raise NotImplementedError()
68 def FlushSystemCacheForDirectory(self, directory, ignoring=None):
69 raise NotImplementedError()