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

Side by Side Diff: base/process_util_win.cc

Issue 18446: Porting in chrome/ (Closed)
Patch Set: last fixes Created 11 years, 11 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 | « base/process_util_posix.cc ('k') | chrome/browser/base_history_model.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 7 #include <windows.h>
8 #include <winternl.h> 8 #include <winternl.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 10
(...skipping 15 matching lines...) Expand all
26 namespace base { 26 namespace base {
27 27
28 int GetCurrentProcId() { 28 int GetCurrentProcId() {
29 return ::GetCurrentProcessId(); 29 return ::GetCurrentProcessId();
30 } 30 }
31 31
32 ProcessHandle GetCurrentProcessHandle() { 32 ProcessHandle GetCurrentProcessHandle() {
33 return ::GetCurrentProcess(); 33 return ::GetCurrentProcess();
34 } 34 }
35 35
36 bool CloseProcessHandle(ProcessHandle process) {
37 return ::CloseHandle(process) ? true : false;
38 }
39
36 // Helper for GetProcId() 40 // Helper for GetProcId()
37 bool GetProcIdViaGetProcessId(ProcessHandle process, DWORD* id) { 41 bool GetProcIdViaGetProcessId(ProcessHandle process, DWORD* id) {
38 // Dynamically get a pointer to GetProcessId(). 42 // Dynamically get a pointer to GetProcessId().
39 typedef DWORD (WINAPI *GetProcessIdFunction)(HANDLE); 43 typedef DWORD (WINAPI *GetProcessIdFunction)(HANDLE);
40 static GetProcessIdFunction GetProcessIdPtr = NULL; 44 static GetProcessIdFunction GetProcessIdPtr = NULL;
41 static bool initialize_get_process_id = true; 45 static bool initialize_get_process_id = true;
42 if (initialize_get_process_id) { 46 if (initialize_get_process_id) {
43 initialize_get_process_id = false; 47 initialize_get_process_id = false;
44 HMODULE kernel32_handle = GetModuleHandle(L"kernel32.dll"); 48 HMODULE kernel32_handle = GetModuleHandle(L"kernel32.dll");
45 if (!kernel32_handle) { 49 if (!kernel32_handle) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return false; 185 return false;
182 } 186 }
183 if (exitcode == STILL_ACTIVE) { 187 if (exitcode == STILL_ACTIVE) {
184 // The process is likely not dead or it used 0x103 as exit code. 188 // The process is likely not dead or it used 0x103 as exit code.
185 NOTREACHED(); 189 NOTREACHED();
186 return false; 190 return false;
187 } 191 }
188 192
189 // Warning, this is not generic code; it heavily depends on the way 193 // Warning, this is not generic code; it heavily depends on the way
190 // the rest of the code kills a process. 194 // the rest of the code kills a process.
191 195
192 if (exitcode == PROCESS_END_NORMAL_TERMINATON || 196 if (exitcode == PROCESS_END_NORMAL_TERMINATON ||
193 exitcode == PROCESS_END_KILLED_BY_USER || 197 exitcode == PROCESS_END_KILLED_BY_USER ||
194 exitcode == PROCESS_END_PROCESS_WAS_HUNG || 198 exitcode == PROCESS_END_PROCESS_WAS_HUNG ||
195 exitcode == 0xC0000354 || // STATUS_DEBUGGER_INACTIVE. 199 exitcode == 0xC0000354 || // STATUS_DEBUGGER_INACTIVE.
196 exitcode == 0xC000013A || // Control-C/end session. 200 exitcode == 0xC000013A || // Control-C/end session.
197 exitcode == 0x40010004) { // Debugger terminated process/end session. 201 exitcode == 0x40010004) { // Debugger terminated process/end session.
198 return false; 202 return false;
199 } 203 }
200 204
201 // All other exit codes indicate crashes. 205 // All other exit codes indicate crashes.
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 void EnableTerminationOnHeapCorruption() { 630 void EnableTerminationOnHeapCorruption() {
627 // Ignore the result code. Supported on XP SP3 and Vista. 631 // Ignore the result code. Supported on XP SP3 and Vista.
628 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 632 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
629 } 633 }
630 634
631 void RaiseProcessToHighPriority() { 635 void RaiseProcessToHighPriority() {
632 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 636 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
633 } 637 }
634 638
635 } // namespace base 639 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_posix.cc ('k') | chrome/browser/base_history_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698