Index: base/process/process_metrics_win.cc |
diff --git a/base/process/process_metrics_win.cc b/base/process/process_metrics_win.cc |
index 24760213f8d0695f1eff3d3c23be0f0e42598a7b..9ef38d5f32e604e31a44f98cfb60cfd1081567fb 100644 |
--- a/base/process/process_metrics_win.cc |
+++ b/base/process/process_metrics_win.cc |
@@ -31,7 +31,10 @@ typedef NTSTATUS(WINAPI* NTQUERYSYSTEMINFORMATION)( |
} // namespace |
-ProcessMetrics::~ProcessMetrics() { } |
+ProcessMetrics::~ProcessMetrics() { |
+ if (process_) |
+ ::CloseHandle(process_); |
brucedawson
2017/03/30 23:09:46
Shouldn't this use a handle wrapper class rather t
stanisc
2017/03/30 23:24:34
It should, but process_ field is defined in the he
|
+} |
// static |
std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics( |
@@ -319,9 +322,16 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { |
} |
ProcessMetrics::ProcessMetrics(ProcessHandle process) |
- : process_(process), |
+ : process_(nullptr), |
processor_count_(SysInfo::NumberOfProcessors()), |
- last_system_time_(0) {} |
+ last_system_time_(0) { |
+ if (process) { |
+ BOOL result = |
+ ::DuplicateHandle(::GetCurrentProcess(), process, ::GetCurrentProcess(), |
+ &process_, PROCESS_QUERY_INFORMATION, FALSE, 0); |
+ DCHECK(result); |
+ } |
+} |
size_t GetSystemCommitCharge() { |
// Get the System Page Size. |