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

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

Issue 2181493002: Return unique_ptrs from base::ProcessMetrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove os_resource_win.* Created 4 years, 5 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.cc » ('j') | base/process/process_metrics_freebsd.cc » ('J')
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
11 #include <stddef.h> 11 #include <stddef.h>
12 #include <stdint.h> 12 #include <stdint.h>
13 13
14 #include <memory>
14 #include <string> 15 #include <string>
15 16
16 #include "base/base_export.h" 17 #include "base/base_export.h"
17 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/process/process_handle.h" 20 #include "base/process/process_handle.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "base/values.h" 22 #include "base/values.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 24
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Provides performance metrics for a specified process (CPU usage, memory and 97 // Provides performance metrics for a specified process (CPU usage, memory and
97 // IO counters). Use CreateCurrentProcessMetrics() to get an instance for the 98 // IO counters). Use CreateCurrentProcessMetrics() to get an instance for the
98 // current process, or CreateProcessMetrics() to get an instance for an 99 // current process, or CreateProcessMetrics() to get an instance for an
99 // arbitrary process. Then, access the information with the different get 100 // arbitrary process. Then, access the information with the different get
100 // methods. 101 // methods.
101 class BASE_EXPORT ProcessMetrics { 102 class BASE_EXPORT ProcessMetrics {
102 public: 103 public:
103 ~ProcessMetrics(); 104 ~ProcessMetrics();
104 105
105 // Creates a ProcessMetrics for the specified process. 106 // Creates a ProcessMetrics for the specified process.
106 // The caller owns the returned object.
107 #if !defined(OS_MACOSX) || defined(OS_IOS) 107 #if !defined(OS_MACOSX) || defined(OS_IOS)
108 static ProcessMetrics* CreateProcessMetrics(ProcessHandle process); 108 static std::unique_ptr<ProcessMetrics> CreateProcessMetrics(
109 ProcessHandle process);
109 #else 110 #else
110 111
111 // The port provider needs to outlive the ProcessMetrics object returned by 112 // The port provider needs to outlive the ProcessMetrics object returned by
112 // this function. If NULL is passed as provider, the returned object 113 // this function. If NULL is passed as provider, the returned object
113 // only returns valid metrics if |process| is the current process. 114 // only returns valid metrics if |process| is the current process.
114 static ProcessMetrics* CreateProcessMetrics(ProcessHandle process, 115 static std::unique_ptr<ProcessMetrics> CreateProcessMetrics(
115 PortProvider* port_provider); 116 ProcessHandle process,
117 PortProvider* port_provider);
116 #endif // !defined(OS_MACOSX) || defined(OS_IOS) 118 #endif // !defined(OS_MACOSX) || defined(OS_IOS)
117 119
118 // Creates a ProcessMetrics for the current process. This a cross-platform 120 // Creates a ProcessMetrics for the current process. This a cross-platform
119 // convenience wrapper for CreateProcessMetrics(). 121 // convenience wrapper for CreateProcessMetrics().
120 // The caller owns the returned object. 122 static std::unique_ptr<ProcessMetrics> CreateCurrentProcessMetrics();
121 static ProcessMetrics* CreateCurrentProcessMetrics();
122 123
123 // Returns the current space allocated for the pagefile, in bytes (these pages 124 // Returns the current space allocated for the pagefile, in bytes (these pages
124 // may or may not be in memory). On Linux, this returns the total virtual 125 // may or may not be in memory). On Linux, this returns the total virtual
125 // memory size. 126 // memory size.
126 size_t GetPagefileUsage() const; 127 size_t GetPagefileUsage() const;
127 // Returns the peak space allocated for the pagefile, in bytes. 128 // Returns the peak space allocated for the pagefile, in bytes.
128 size_t GetPeakPagefileUsage() const; 129 size_t GetPeakPagefileUsage() const;
129 // Returns the current working set size, in bytes. On Linux, this returns 130 // Returns the current working set size, in bytes. On Linux, this returns
130 // the resident set size. 131 // the resident set size.
131 size_t GetWorkingSetSize() const; 132 size_t GetWorkingSetSize() const;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 SystemDiskInfo disk_info_; 424 SystemDiskInfo disk_info_;
424 #endif 425 #endif
425 #if defined(OS_CHROMEOS) 426 #if defined(OS_CHROMEOS)
426 SwapInfo swap_info_; 427 SwapInfo swap_info_;
427 #endif 428 #endif
428 }; 429 };
429 430
430 } // namespace base 431 } // namespace base
431 432
432 #endif // BASE_PROCESS_PROCESS_METRICS_H_ 433 #endif // BASE_PROCESS_PROCESS_METRICS_H_
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics.cc » ('j') | base/process/process_metrics_freebsd.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698