Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / platform / cros_platform_backend.py
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.
4
5 from telemetry.core.platform import proc_supporting_platform_backend
6 from telemetry.core.platform import ps_util
7
8
9 class CrosPlatformBackend(
10     proc_supporting_platform_backend.ProcSupportingPlatformBackend):
11
12   def __init__(self, cri):
13     super(CrosPlatformBackend, self).__init__()
14     self._cri = cri
15
16   def StartRawDisplayFrameRateMeasurement(self):
17     raise NotImplementedError()
18
19   def StopRawDisplayFrameRateMeasurement(self):
20     raise NotImplementedError()
21
22   def GetRawDisplayFrameRateMeasurements(self):
23     raise NotImplementedError()
24
25   def IsThermallyThrottled(self):
26     raise NotImplementedError()
27
28   def HasBeenThermallyThrottled(self):
29     raise NotImplementedError()
30
31   def _RunCommand(self, args):
32     return self._cri.RunCmdOnDevice(args)[0]
33
34   def _GetFileContents(self, filename):
35     try:
36       return self._cri.RunCmdOnDevice(['cat', filename])[0]
37     except AssertionError:
38       return ''
39
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.
43     return {}
44
45   def GetOSName(self):
46     return 'chromeos'
47
48   def GetOSVersionName(self):
49     return ''  # TODO: Implement this.
50
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)
57
58   def GetCommandLine(self, pid):
59     procs = self._cri.ListProcesses()
60     return next((proc[1] for proc in procs if proc[0] == pid), None)
61
62   def CanFlushIndividualFilesFromSystemCache(self):
63     return True
64
65   def FlushEntireSystemCache(self):
66     raise NotImplementedError()
67
68   def FlushSystemCacheForDirectory(self, directory, ignoring=None):
69     raise NotImplementedError()