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_util_win.cc

Issue 371025: More memory stats code cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: multiply uses by 1024 to keep stats consistent with old runs Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_util.h" 5 #include "base/process_util.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <windows.h> 9 #include <windows.h>
10 #include <winternl.h> 10 #include <winternl.h>
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // signal() handling in process_util_posix.cc. 792 // signal() handling in process_util_posix.cc.
793 g_previous_filter = SetUnhandledExceptionFilter(&StackDumpExceptionFilter); 793 g_previous_filter = SetUnhandledExceptionFilter(&StackDumpExceptionFilter);
794 AttachToConsole(); 794 AttachToConsole();
795 return true; 795 return true;
796 } 796 }
797 797
798 void RaiseProcessToHighPriority() { 798 void RaiseProcessToHighPriority() {
799 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 799 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
800 } 800 }
801 801
802 // GetPerformanceInfo is not available on WIN2K. So we'll
803 // load it on-the-fly.
804 const wchar_t kPsapiDllName[] = L"psapi.dll";
805 typedef BOOL (WINAPI *GetPerformanceInfoFunction) (
806 PPERFORMANCE_INFORMATION pPerformanceInformation,
807 DWORD cb);
808
809 // Beware of races if called concurrently from multiple threads.
810 static BOOL InternalGetPerformanceInfo(
811 PPERFORMANCE_INFORMATION pPerformanceInformation, DWORD cb) {
812 static GetPerformanceInfoFunction GetPerformanceInfo_func = NULL;
813 if (!GetPerformanceInfo_func) {
814 HMODULE psapi_dll = ::GetModuleHandle(kPsapiDllName);
815 if (psapi_dll)
816 GetPerformanceInfo_func = reinterpret_cast<GetPerformanceInfoFunction>(
817 GetProcAddress(psapi_dll, "GetPerformanceInfo"));
818
819 if (!GetPerformanceInfo_func) {
820 // The function could be loaded!
821 memset(pPerformanceInformation, 0, cb);
822 return FALSE;
823 }
824 }
825 return GetPerformanceInfo_func(pPerformanceInformation, cb);
826 }
827
828 size_t GetSystemCommitCharge() {
829 // Get the System Page Size.
830 SYSTEM_INFO system_info;
831 GetSystemInfo(&system_info);
832
833 PERFORMANCE_INFORMATION info;
834 if (! InternalGetPerformanceInfo(&info, sizeof(info))) {
835 LOG(ERROR) << "Failed to fetch internal performance info.";
vandebo (ex-Chrome) 2009/11/09 19:10:29 Error/Warning ?
836 return 0;
837 }
838 return (info.CommitTotal * system_info.dwPageSize) / 1024;
839 }
840
802 } // namespace base 841 } // namespace base
OLDNEW
« base/process_util_linux.cc ('K') | « base/process_util_mac.mm ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698