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

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

Issue 2858213002: Clean up base/process/process_metrics_linux.cc. (Closed)
Patch Set: constexpr is too much Created 3 years, 7 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // Exposed for memory debugging widget. 385 // Exposed for memory debugging widget.
386 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); 386 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
387 387
388 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || 388 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) ||
389 // defined(OS_ANDROID) 389 // defined(OS_ANDROID)
390 390
391 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_AIX) 391 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_AIX)
392 // Parse the data found in /proc/<pid>/stat and return the sum of the 392 // Parse the data found in /proc/<pid>/stat and return the sum of the
393 // CPU-related ticks. Returns -1 on parse error. 393 // CPU-related ticks. Returns -1 on parse error.
394 // Exposed for testing. 394 // Exposed for testing.
395 BASE_EXPORT int ParseProcStatCPU(const std::string& input); 395 BASE_EXPORT int ParseProcStatCPU(StringPiece input);
396 396
397 // Get the number of threads of |process| as available in /proc/<pid>/stat. 397 // Get the number of threads of |process| as available in /proc/<pid>/stat.
398 // This should be used with care as no synchronization with running threads is 398 // This should be used with care as no synchronization with running threads is
399 // done. This is mostly useful to guarantee being single-threaded. 399 // done. This is mostly useful to guarantee being single-threaded.
400 // Returns 0 on failure. 400 // Returns 0 on failure.
401 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process); 401 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process);
402 402
403 // /proc/self/exe refers to the current executable. 403 // /proc/self/exe refers to the current executable.
404 BASE_EXPORT extern const char kProcSelfExe[]; 404 BASE_EXPORT extern const char kProcSelfExe[];
405 405
406 // Parses a string containing the contents of /proc/meminfo 406 // Parses a string containing the contents of /proc/meminfo
407 // returns true on success or false for a parsing error 407 // returns true on success or false for a parsing error
408 BASE_EXPORT bool ParseProcMeminfo(const std::string& input, 408 // Exposed for testing.
409 BASE_EXPORT bool ParseProcMeminfo(StringPiece input,
409 SystemMemoryInfoKB* meminfo); 410 SystemMemoryInfoKB* meminfo);
410 411
411 // Parses a string containing the contents of /proc/vmstat 412 // Parses a string containing the contents of /proc/vmstat
412 // returns true on success or false for a parsing error 413 // returns true on success or false for a parsing error
413 BASE_EXPORT bool ParseProcVmstat(const std::string& input, 414 // Exposed for testing.
415 BASE_EXPORT bool ParseProcVmstat(StringPiece input,
414 SystemMemoryInfoKB* meminfo); 416 SystemMemoryInfoKB* meminfo);
415 417
416 // Data from /proc/diskstats about system-wide disk I/O. 418 // Data from /proc/diskstats about system-wide disk I/O.
417 struct BASE_EXPORT SystemDiskInfo { 419 struct BASE_EXPORT SystemDiskInfo {
418 SystemDiskInfo(); 420 SystemDiskInfo();
419 SystemDiskInfo(const SystemDiskInfo& other); 421 SystemDiskInfo(const SystemDiskInfo& other);
420 422
421 // Serializes the platform specific fields to value. 423 // Serializes the platform specific fields to value.
422 std::unique_ptr<Value> ToValue() const; 424 std::unique_ptr<Value> ToValue() const;
423 425
424 uint64_t reads; 426 uint64_t reads;
425 uint64_t reads_merged; 427 uint64_t reads_merged;
426 uint64_t sectors_read; 428 uint64_t sectors_read;
427 uint64_t read_time; 429 uint64_t read_time;
428 uint64_t writes; 430 uint64_t writes;
429 uint64_t writes_merged; 431 uint64_t writes_merged;
430 uint64_t sectors_written; 432 uint64_t sectors_written;
431 uint64_t write_time; 433 uint64_t write_time;
432 uint64_t io; 434 uint64_t io;
433 uint64_t io_time; 435 uint64_t io_time;
434 uint64_t weighted_io_time; 436 uint64_t weighted_io_time;
435 }; 437 };
436 438
437 // Checks whether the candidate string is a valid disk name, [hsv]d[a-z]+ 439 // Checks whether the candidate string is a valid disk name, [hsv]d[a-z]+
438 // for a generic disk or mmcblk[0-9]+ for the MMC case. 440 // for a generic disk or mmcblk[0-9]+ for the MMC case.
439 // Names of disk partitions (e.g. sda1) are not valid. 441 // Names of disk partitions (e.g. sda1) are not valid.
440 BASE_EXPORT bool IsValidDiskName(const std::string& candidate); 442 BASE_EXPORT bool IsValidDiskName(StringPiece candidate);
441 443
442 // Retrieves data from /proc/diskstats about system-wide disk I/O. 444 // Retrieves data from /proc/diskstats about system-wide disk I/O.
443 // Fills in the provided |diskinfo| structure. Returns true on success. 445 // Fills in the provided |diskinfo| structure. Returns true on success.
444 BASE_EXPORT bool GetSystemDiskInfo(SystemDiskInfo* diskinfo); 446 BASE_EXPORT bool GetSystemDiskInfo(SystemDiskInfo* diskinfo);
445 447
446 // Returns the amount of time spent in user space since boot across all CPUs. 448 // Returns the amount of time spent in user space since boot across all CPUs.
447 BASE_EXPORT TimeDelta GetUserCpuTimeSinceBoot(); 449 BASE_EXPORT TimeDelta GetUserCpuTimeSinceBoot();
448 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 450 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
449 451
450 #if defined(OS_CHROMEOS) 452 #if defined(OS_CHROMEOS)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // |size| and |info| are output parameters, only valid on Success. 532 // |size| and |info| are output parameters, only valid on Success.
531 BASE_EXPORT MachVMRegionResult GetBasicInfo(mach_port_t task, 533 BASE_EXPORT MachVMRegionResult GetBasicInfo(mach_port_t task,
532 mach_vm_size_t* size, 534 mach_vm_size_t* size,
533 mach_vm_address_t* address, 535 mach_vm_address_t* address,
534 vm_region_basic_info_64* info); 536 vm_region_basic_info_64* info);
535 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 537 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
536 538
537 } // namespace base 539 } // namespace base
538 540
539 #endif // BASE_PROCESS_PROCESS_METRICS_H_ 541 #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