| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 else if (key == "wchar") | 282 else if (key == "wchar") |
| 283 target_counter = &io_counters->WriteTransferCount; | 283 target_counter = &io_counters->WriteTransferCount; |
| 284 if (!target_counter) | 284 if (!target_counter) |
| 285 continue; | 285 continue; |
| 286 bool converted = StringToUint64(value_str, target_counter); | 286 bool converted = StringToUint64(value_str, target_counter); |
| 287 DCHECK(converted); | 287 DCHECK(converted); |
| 288 } | 288 } |
| 289 return true; | 289 return true; |
| 290 } | 290 } |
| 291 | 291 |
| 292 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 293 uint64_t ProcessMetrics::GetVmSwapBytes() const { |
| 294 return ReadProcStatusAndGetFieldAsSizeT(process_, "VmSwap") * 1024; |
| 295 } |
| 296 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 297 |
| 292 #if defined(OS_LINUX) || defined(OS_AIX) | 298 #if defined(OS_LINUX) || defined(OS_AIX) |
| 293 int ProcessMetrics::GetOpenFdCount() const { | 299 int ProcessMetrics::GetOpenFdCount() const { |
| 294 // Use /proc/<pid>/fd to count the number of entries there. | 300 // Use /proc/<pid>/fd to count the number of entries there. |
| 295 FilePath fd_path = internal::GetProcPidDir(process_).Append("fd"); | 301 FilePath fd_path = internal::GetProcPidDir(process_).Append("fd"); |
| 296 | 302 |
| 297 DirReaderPosix dir_reader(fd_path.value().c_str()); | 303 DirReaderPosix dir_reader(fd_path.value().c_str()); |
| 298 if (!dir_reader.IsValid()) | 304 if (!dir_reader.IsValid()) |
| 299 return -1; | 305 return -1; |
| 300 | 306 |
| 301 int total_count = 0; | 307 int total_count = 0; |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 955 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
| 950 uint64_t num_switches; | 956 uint64_t num_switches; |
| 951 static const char kSwitchStat[] = "voluntary_ctxt_switches"; | 957 static const char kSwitchStat[] = "voluntary_ctxt_switches"; |
| 952 return ReadProcStatusAndGetFieldAsUint64(process_, kSwitchStat, &num_switches) | 958 return ReadProcStatusAndGetFieldAsUint64(process_, kSwitchStat, &num_switches) |
| 953 ? CalculateIdleWakeupsPerSecond(num_switches) | 959 ? CalculateIdleWakeupsPerSecond(num_switches) |
| 954 : 0; | 960 : 0; |
| 955 } | 961 } |
| 956 #endif // defined(OS_LINUX) || defined(OS_AIX) | 962 #endif // defined(OS_LINUX) || defined(OS_AIX) |
| 957 | 963 |
| 958 } // namespace base | 964 } // namespace base |
| OLD | NEW |