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

Side by Side Diff: base/process_util_win.cc

Issue 9121046: Cleanup in ProcessSingleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « base/process_util_unittest.cc ('k') | chrome/browser/process_singleton_win.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <userenv.h> 10 #include <userenv.h>
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } // namespace 167 } // namespace
168 168
169 ProcessId GetCurrentProcId() { 169 ProcessId GetCurrentProcId() {
170 return ::GetCurrentProcessId(); 170 return ::GetCurrentProcessId();
171 } 171 }
172 172
173 ProcessHandle GetCurrentProcessHandle() { 173 ProcessHandle GetCurrentProcessHandle() {
174 return ::GetCurrentProcess(); 174 return ::GetCurrentProcess();
175 } 175 }
176 176
177 HMODULE GetModuleFromAddress(void* address) {
178 HMODULE hinst = NULL;
179 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
180 static_cast<char*>(address),
181 &hinst)) {
182 NOTREACHED();
183 }
184 return hinst;
185 }
186
177 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { 187 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
178 // We try to limit privileges granted to the handle. If you need this 188 // We try to limit privileges granted to the handle. If you need this
179 // for test code, consider using OpenPrivilegedProcessHandle instead of 189 // for test code, consider using OpenPrivilegedProcessHandle instead of
180 // adding more privileges here. 190 // adding more privileges here.
181 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE, 191 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE,
182 FALSE, pid); 192 FALSE, pid);
183 193
184 if (result == INVALID_HANDLE_VALUE) 194 if (result == INVALID_HANDLE_VALUE)
185 return false; 195 return false;
186 196
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 1002
993 PERFORMANCE_INFORMATION info; 1003 PERFORMANCE_INFORMATION info;
994 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { 1004 if (!InternalGetPerformanceInfo(&info, sizeof(info))) {
995 DLOG(ERROR) << "Failed to fetch internal performance info."; 1005 DLOG(ERROR) << "Failed to fetch internal performance info.";
996 return 0; 1006 return 0;
997 } 1007 }
998 return (info.CommitTotal * system_info.dwPageSize) / 1024; 1008 return (info.CommitTotal * system_info.dwPageSize) / 1024;
999 } 1009 }
1000 1010
1001 } // namespace base 1011 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_unittest.cc ('k') | chrome/browser/process_singleton_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698