Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: base/process/process_metrics.h

Issue 1384363002: [NOT TO COMMIT YET] Using proc/pid/status file contents to get process metrics in linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@smaps_fscan
Patch Set: Fixes. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/process/process_metrics_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698