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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 309 |
310 std::string totmaps_data; | 310 std::string totmaps_data; |
311 { | 311 { |
312 FilePath totmaps_file = internal::GetProcPidDir(process_).Append("totmaps"); | 312 FilePath totmaps_file = internal::GetProcPidDir(process_).Append("totmaps"); |
313 ThreadRestrictions::ScopedAllowIO allow_io; | 313 ThreadRestrictions::ScopedAllowIO allow_io; |
314 bool ret = ReadFileToString(totmaps_file, &totmaps_data); | 314 bool ret = ReadFileToString(totmaps_file, &totmaps_data); |
315 if (!ret || totmaps_data.length() == 0) | 315 if (!ret || totmaps_data.length() == 0) |
316 return false; | 316 return false; |
317 } | 317 } |
318 | 318 |
319 std::vector<std::string> totmaps_fields; | 319 std::vector<std::string> totmaps_fields = SplitString( |
320 SplitStringAlongWhitespace(totmaps_data, &totmaps_fields); | 320 totmaps_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, |
| 321 base::SPLIT_WANT_NONEMPTY); |
321 | 322 |
322 DCHECK_EQ("Pss:", totmaps_fields[kPssIndex-1]); | 323 DCHECK_EQ("Pss:", totmaps_fields[kPssIndex-1]); |
323 DCHECK_EQ("Private_Clean:", totmaps_fields[kPrivate_CleanIndex - 1]); | 324 DCHECK_EQ("Private_Clean:", totmaps_fields[kPrivate_CleanIndex - 1]); |
324 DCHECK_EQ("Private_Dirty:", totmaps_fields[kPrivate_DirtyIndex - 1]); | 325 DCHECK_EQ("Private_Dirty:", totmaps_fields[kPrivate_DirtyIndex - 1]); |
325 DCHECK_EQ("Swap:", totmaps_fields[kSwapIndex-1]); | 326 DCHECK_EQ("Swap:", totmaps_fields[kSwapIndex-1]); |
326 | 327 |
327 int pss = 0; | 328 int pss = 0; |
328 int private_clean = 0; | 329 int private_clean = 0; |
329 int private_dirty = 0; | 330 int private_dirty = 0; |
330 int swap = 0; | 331 int swap = 0; |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 #if defined(OS_LINUX) | 904 #if defined(OS_LINUX) |
904 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 905 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
905 uint64 wake_ups; | 906 uint64 wake_ups; |
906 const char kWakeupStat[] = "se.statistics.nr_wakeups"; | 907 const char kWakeupStat[] = "se.statistics.nr_wakeups"; |
907 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? | 908 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? |
908 CalculateIdleWakeupsPerSecond(wake_ups) : 0; | 909 CalculateIdleWakeupsPerSecond(wake_ups) : 0; |
909 } | 910 } |
910 #endif // defined(OS_LINUX) | 911 #endif // defined(OS_LINUX) |
911 | 912 |
912 } // namespace base | 913 } // namespace base |
OLD | NEW |