| 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 #include "base/process/process_metrics.h" | 5 #include "base/process/process_metrics.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <psapi.h> | 8 #include <psapi.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 static BOOL InternalGetPerformanceInfo( | 253 static BOOL InternalGetPerformanceInfo( |
| 254 PPERFORMANCE_INFORMATION pPerformanceInformation, DWORD cb) { | 254 PPERFORMANCE_INFORMATION pPerformanceInformation, DWORD cb) { |
| 255 static GetPerformanceInfoFunction GetPerformanceInfo_func = NULL; | 255 static GetPerformanceInfoFunction GetPerformanceInfo_func = NULL; |
| 256 if (!GetPerformanceInfo_func) { | 256 if (!GetPerformanceInfo_func) { |
| 257 HMODULE psapi_dll = ::GetModuleHandle(kPsapiDllName); | 257 HMODULE psapi_dll = ::GetModuleHandle(kPsapiDllName); |
| 258 if (psapi_dll) | 258 if (psapi_dll) |
| 259 GetPerformanceInfo_func = reinterpret_cast<GetPerformanceInfoFunction>( | 259 GetPerformanceInfo_func = reinterpret_cast<GetPerformanceInfoFunction>( |
| 260 GetProcAddress(psapi_dll, "GetPerformanceInfo")); | 260 GetProcAddress(psapi_dll, "GetPerformanceInfo")); |
| 261 | 261 |
| 262 if (!GetPerformanceInfo_func) { | 262 if (!GetPerformanceInfo_func) { |
| 263 // The function could be loaded! | 263 // The function could not be loaded! |
| 264 memset(pPerformanceInformation, 0, cb); | 264 memset(pPerformanceInformation, 0, cb); |
| 265 return FALSE; | 265 return FALSE; |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 return GetPerformanceInfo_func(pPerformanceInformation, cb); | 268 return GetPerformanceInfo_func(pPerformanceInformation, cb); |
| 269 } | 269 } |
| 270 | 270 |
| 271 size_t GetSystemCommitCharge() { | 271 size_t GetSystemCommitCharge() { |
| 272 // Get the System Page Size. | 272 // Get the System Page Size. |
| 273 SYSTEM_INFO system_info; | 273 SYSTEM_INFO system_info; |
| 274 GetSystemInfo(&system_info); | 274 GetSystemInfo(&system_info); |
| 275 | 275 |
| 276 PERFORMANCE_INFORMATION info; | 276 PERFORMANCE_INFORMATION info; |
| 277 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 277 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
| 278 DLOG(ERROR) << "Failed to fetch internal performance info."; | 278 DLOG(ERROR) << "Failed to fetch internal performance info."; |
| 279 return 0; | 279 return 0; |
| 280 } | 280 } |
| 281 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 281 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
| 282 } | 282 } |
| 283 | 283 |
| 284 size_t GetPageSize() { | 284 size_t GetPageSize() { |
| 285 return PAGESIZE_KB * 1024; | 285 return PAGESIZE_KB * 1024; |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace base | 288 } // namespace base |
| OLD | NEW |