OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/process/process_metrics.h" | 5 #include "base/process/process_metrics.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 return 0; | 79 return 0; |
80 } | 80 } |
81 size_t value; | 81 size_t value; |
82 if (!StringToSizeT(split_value_str[0], &value)) { | 82 if (!StringToSizeT(split_value_str[0], &value)) { |
83 NOTREACHED(); | 83 NOTREACHED(); |
84 return 0; | 84 return 0; |
85 } | 85 } |
86 return value; | 86 return value; |
87 } | 87 } |
88 } | 88 } |
89 NOTREACHED(); | |
Primiano Tucci (use gerrit)
2016/01/05 11:55:17
hmm if you do this I think you need to turn this i
ssid
2016/01/06 20:26:33
I think this dcheck should not exist since it is o
| |
90 return 0; | 89 return 0; |
91 } | 90 } |
92 | 91 |
93 #if defined(OS_LINUX) | 92 #if defined(OS_LINUX) |
94 // Read /proc/<pid>/sched and look for |field|. On succes, return true and | 93 // Read /proc/<pid>/sched and look for |field|. On succes, return true and |
95 // write the value for |field| into |result|. | 94 // write the value for |field| into |result|. |
96 // Only works for fields in the form of "field : uint_value" | 95 // Only works for fields in the form of "field : uint_value" |
97 bool ReadProcSchedAndGetFieldAsUint64(pid_t pid, | 96 bool ReadProcSchedAndGetFieldAsUint64(pid_t pid, |
98 const std::string& field, | 97 const std::string& field, |
99 uint64_t* result) { | 98 uint64_t* result) { |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 #if defined(OS_LINUX) | 940 #if defined(OS_LINUX) |
942 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 941 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
943 uint64_t wake_ups; | 942 uint64_t wake_ups; |
944 const char kWakeupStat[] = "se.statistics.nr_wakeups"; | 943 const char kWakeupStat[] = "se.statistics.nr_wakeups"; |
945 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? | 944 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? |
946 CalculateIdleWakeupsPerSecond(wake_ups) : 0; | 945 CalculateIdleWakeupsPerSecond(wake_ups) : 0; |
947 } | 946 } |
948 #endif // defined(OS_LINUX) | 947 #endif // defined(OS_LINUX) |
949 | 948 |
950 } // namespace base | 949 } // namespace base |
OLD | NEW |