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

Side by Side Diff: base/process_util_win.cc

Issue 10895: Add Terminate() to the Process object, have RenderProcessHost use this to avo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 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
« no previous file with comments | « base/process_util_unittest.cc ('k') | base/process_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) 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
11 #include "base/histogram.h" 11 #include "base/histogram.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 14
15 namespace { 15 namespace {
16 16
17 // System pagesize. This value remains constant on x86/64 architectures. 17 // System pagesize. This value remains constant on x86/64 architectures.
18 const int PAGESIZE_KB = 4; 18 const int PAGESIZE_KB = 4;
19 19
20 // HeapSetInformation function pointer. 20 // HeapSetInformation function pointer.
21 typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T); 21 typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
22 22
23 } // namespace 23 } // namespace
24 24
25 namespace process_util { 25 namespace base {
26 26
27 int GetCurrentProcId() { 27 int GetCurrentProcId() {
28 return ::GetCurrentProcessId(); 28 return ::GetCurrentProcessId();
29 } 29 }
30 30
31 ProcessHandle GetCurrentProcessHandle() { 31 ProcessHandle GetCurrentProcessHandle() {
32 return ::GetCurrentProcess(); 32 return ::GetCurrentProcess();
33 } 33 }
34 34
35 // Helper for GetProcId() 35 // Helper for GetProcId()
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) { 324 bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) {
325 bool retval = WaitForSingleObject(handle, wait_milliseconds) == WAIT_OBJECT_0; 325 bool retval = WaitForSingleObject(handle, wait_milliseconds) == WAIT_OBJECT_0;
326 CloseHandle(handle); 326 CloseHandle(handle);
327 return retval; 327 return retval;
328 } 328 }
329 329
330 bool CleanupProcesses(const std::wstring& executable_name, 330 bool CleanupProcesses(const std::wstring& executable_name,
331 int wait_milliseconds, 331 int wait_milliseconds,
332 int exit_code, 332 int exit_code,
333 const ProcessFilter* filter) { 333 const ProcessFilter* filter) {
334 bool exited_cleanly = 334 bool exited_cleanly = WaitForProcessesToExit(executable_name,
335 process_util::WaitForProcessesToExit(executable_name, wait_milliseconds, 335 wait_milliseconds,
336 filter); 336 filter);
337 if (!exited_cleanly) 337 if (!exited_cleanly)
338 process_util::KillProcesses(executable_name, exit_code, filter); 338 KillProcesses(executable_name, exit_code, filter);
339 return exited_cleanly; 339 return exited_cleanly;
340 } 340 }
341 341
342 /////////////////////////////////////////////////////////////////////////////// 342 ///////////////////////////////////////////////////////////////////////////////
343 // ProcesMetrics 343 // ProcesMetrics
344 344
345 ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process), 345 ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process),
346 last_time_(0), 346 last_time_(0),
347 last_system_time_(0) { 347 last_system_time_(0) {
348 SYSTEM_INFO system_info; 348 SYSTEM_INFO system_info;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 610
611 void EnableTerminationOnHeapCorruption() { 611 void EnableTerminationOnHeapCorruption() {
612 // Ignore the result code. Supported on XP SP3 and Vista. 612 // Ignore the result code. Supported on XP SP3 and Vista.
613 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 613 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
614 } 614 }
615 615
616 void RaiseProcessToHighPriority() { 616 void RaiseProcessToHighPriority() {
617 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 617 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
618 } 618 }
619 619
620 } // namespace process_util 620 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_unittest.cc ('k') | base/process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698