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

Side by Side Diff: base/process/process_win.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/process_unittest.cc ('k') | base/profiler/tracked_time.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "base/process/process.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/kill.h"
9 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 Process::Process(ProcessHandle handle) 14 Process::Process(ProcessHandle handle)
14 : is_current_process_(false), 15 : is_current_process_(false),
15 process_(handle) { 16 process_(handle) {
16 CHECK_NE(handle, ::GetCurrentProcess()); 17 CHECK_NE(handle, ::GetCurrentProcess());
17 } 18 }
18 19
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Call NtTerminateProcess directly, without going through the import table, 104 // Call NtTerminateProcess directly, without going through the import table,
104 // which might have been hooked with a buggy replacement by third party 105 // which might have been hooked with a buggy replacement by third party
105 // software. http://crbug.com/81449. 106 // software. http://crbug.com/81449.
106 HMODULE module = GetModuleHandle(L"ntdll.dll"); 107 HMODULE module = GetModuleHandle(L"ntdll.dll");
107 typedef UINT (WINAPI *TerminateProcessPtr)(HANDLE handle, UINT code); 108 typedef UINT (WINAPI *TerminateProcessPtr)(HANDLE handle, UINT code);
108 TerminateProcessPtr terminate_process = reinterpret_cast<TerminateProcessPtr>( 109 TerminateProcessPtr terminate_process = reinterpret_cast<TerminateProcessPtr>(
109 GetProcAddress(module, "NtTerminateProcess")); 110 GetProcAddress(module, "NtTerminateProcess"));
110 terminate_process(Handle(), result_code); 111 terminate_process(Handle(), result_code);
111 } 112 }
112 113
114 bool Process::WaitForExit(int* exit_code) {
115 return WaitForExitWithTimeout(TimeDelta::FromMilliseconds(INFINITE),
116 exit_code);
117 }
118
119 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) {
120 // TODO(rvargas) crbug.com/417532: Move the implementation here.
121 if (timeout > TimeDelta::FromMilliseconds(INFINITE))
122 timeout = TimeDelta::FromMilliseconds(INFINITE);
123 return base::WaitForExitCodeWithTimeout(Handle(), exit_code, timeout);
124 }
125
113 bool Process::IsProcessBackgrounded() const { 126 bool Process::IsProcessBackgrounded() const {
114 DCHECK(IsValid()); 127 DCHECK(IsValid());
115 DWORD priority = GetPriority(); 128 DWORD priority = GetPriority();
116 if (priority == 0) 129 if (priority == 0)
117 return false; // Failure case. 130 return false; // Failure case.
118 return ((priority == BELOW_NORMAL_PRIORITY_CLASS) || 131 return ((priority == BELOW_NORMAL_PRIORITY_CLASS) ||
119 (priority == IDLE_PRIORITY_CLASS)); 132 (priority == IDLE_PRIORITY_CLASS));
120 } 133 }
121 134
122 bool Process::SetProcessBackgrounded(bool value) { 135 bool Process::SetProcessBackgrounded(bool value) {
(...skipping 11 matching lines...) Expand all
134 147
135 return (::SetPriorityClass(Handle(), priority) != 0); 148 return (::SetPriorityClass(Handle(), priority) != 0);
136 } 149 }
137 150
138 int Process::GetPriority() const { 151 int Process::GetPriority() const {
139 DCHECK(IsValid()); 152 DCHECK(IsValid());
140 return ::GetPriorityClass(Handle()); 153 return ::GetPriorityClass(Handle());
141 } 154 }
142 155
143 } // namespace base 156 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_unittest.cc ('k') | base/profiler/tracked_time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698