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 <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/time.h> | 10 #include <sys/time.h> |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 384 } |
385 | 385 |
386 // Exposed for testing. | 386 // Exposed for testing. |
387 int ParseProcStatCPU(const std::string& input) { | 387 int ParseProcStatCPU(const std::string& input) { |
388 std::vector<std::string> proc_stats; | 388 std::vector<std::string> proc_stats; |
389 if (!internal::ParseProcStats(input, &proc_stats)) | 389 if (!internal::ParseProcStats(input, &proc_stats)) |
390 return -1; | 390 return -1; |
391 | 391 |
392 if (proc_stats.size() <= internal::VM_STIME) | 392 if (proc_stats.size() <= internal::VM_STIME) |
393 return -1; | 393 return -1; |
394 int utime = GetProcStatsFieldAsInt(proc_stats, internal::VM_UTIME); | 394 int utime = GetProcStatsFieldAsInt64(proc_stats, internal::VM_UTIME); |
395 int stime = GetProcStatsFieldAsInt(proc_stats, internal::VM_STIME); | 395 int stime = GetProcStatsFieldAsInt64(proc_stats, internal::VM_STIME); |
396 return utime + stime; | 396 return utime + stime; |
397 } | 397 } |
398 | 398 |
399 const char kProcSelfExe[] = "/proc/self/exe"; | 399 const char kProcSelfExe[] = "/proc/self/exe"; |
400 | 400 |
401 int GetNumberOfThreads(ProcessHandle process) { | 401 int GetNumberOfThreads(ProcessHandle process) { |
402 return internal::ReadProcStatsAndGetFieldAsInt(process, | 402 return internal::ReadProcStatsAndGetFieldAsInt64(process, |
403 internal::VM_NUMTHREADS); | 403 internal::VM_NUMTHREADS); |
404 } | 404 } |
405 | 405 |
406 namespace { | 406 namespace { |
407 | 407 |
408 // The format of /proc/diskstats is: | 408 // The format of /proc/diskstats is: |
409 // Device major number | 409 // Device major number |
410 // Device minor number | 410 // Device minor number |
411 // Device name | 411 // Device name |
412 // Field 1 -- # of reads completed | 412 // Field 1 -- # of reads completed |
413 // This is the total number of reads completed successfully. | 413 // This is the total number of reads completed successfully. |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 swap_info->num_reads = ReadFileToUint64(zram_path.Append("num_reads")); | 874 swap_info->num_reads = ReadFileToUint64(zram_path.Append("num_reads")); |
875 swap_info->num_writes = ReadFileToUint64(zram_path.Append("num_writes")); | 875 swap_info->num_writes = ReadFileToUint64(zram_path.Append("num_writes")); |
876 swap_info->compr_data_size = | 876 swap_info->compr_data_size = |
877 ReadFileToUint64(zram_path.Append("compr_data_size")); | 877 ReadFileToUint64(zram_path.Append("compr_data_size")); |
878 swap_info->mem_used_total = | 878 swap_info->mem_used_total = |
879 ReadFileToUint64(zram_path.Append("mem_used_total")); | 879 ReadFileToUint64(zram_path.Append("mem_used_total")); |
880 } | 880 } |
881 #endif // defined(OS_CHROMEOS) | 881 #endif // defined(OS_CHROMEOS) |
882 | 882 |
883 } // namespace base | 883 } // namespace base |
OLD | NEW |