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 // This file contains routines for gathering resource statistics for processes | 5 // This file contains routines for gathering resource statistics for processes |
6 // running on the system. | 6 // running on the system. |
7 | 7 |
8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_ | 8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_ |
9 #define BASE_PROCESS_PROCESS_METRICS_H_ | 9 #define BASE_PROCESS_PROCESS_METRICS_H_ |
10 | 10 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || | 301 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || |
302 // defined(OS_ANDROID) | 302 // defined(OS_ANDROID) |
303 | 303 |
304 #if defined(OS_LINUX) || defined(OS_ANDROID) | 304 #if defined(OS_LINUX) || defined(OS_ANDROID) |
305 // Parse the data found in /proc/<pid>/stat and return the sum of the | 305 // Parse the data found in /proc/<pid>/stat and return the sum of the |
306 // CPU-related ticks. Returns -1 on parse error. | 306 // CPU-related ticks. Returns -1 on parse error. |
307 // Exposed for testing. | 307 // Exposed for testing. |
308 BASE_EXPORT int ParseProcStatCPU(const std::string& input); | 308 BASE_EXPORT int ParseProcStatCPU(const std::string& input); |
309 | 309 |
| 310 // Parses the /proc/<pid>/status file contents passed and sets |value| to the |
| 311 // size in bytes corresponding to the |field|. Only works for fields in the form |
| 312 // of "Field: value kB". Returns true on success. |
| 313 BASE_EXPORT bool ParseProcStatusAndGetField( |
| 314 const base::StringPiece& proc_status_contents, |
| 315 const std::string& field, |
| 316 size_t* value); |
| 317 |
310 // Get the number of threads of |process| as available in /proc/<pid>/stat. | 318 // Get the number of threads of |process| as available in /proc/<pid>/stat. |
311 // This should be used with care as no synchronization with running threads is | 319 // This should be used with care as no synchronization with running threads is |
312 // done. This is mostly useful to guarantee being single-threaded. | 320 // done. This is mostly useful to guarantee being single-threaded. |
313 // Returns 0 on failure. | 321 // Returns 0 on failure. |
314 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process); | 322 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process); |
315 | 323 |
316 // /proc/self/exe refers to the current executable. | 324 // /proc/self/exe refers to the current executable. |
317 BASE_EXPORT extern const char kProcSelfExe[]; | 325 BASE_EXPORT extern const char kProcSelfExe[]; |
318 | 326 |
319 // Parses a string containing the contents of /proc/meminfo | 327 // Parses a string containing the contents of /proc/meminfo |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 SystemDiskInfo disk_info_; | 411 SystemDiskInfo disk_info_; |
404 #endif | 412 #endif |
405 #if defined(OS_CHROMEOS) | 413 #if defined(OS_CHROMEOS) |
406 SwapInfo swap_info_; | 414 SwapInfo swap_info_; |
407 #endif | 415 #endif |
408 }; | 416 }; |
409 | 417 |
410 } // namespace base | 418 } // namespace base |
411 | 419 |
412 #endif // BASE_PROCESS_PROCESS_METRICS_H_ | 420 #endif // BASE_PROCESS_PROCESS_METRICS_H_ |
OLD | NEW |