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

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

Issue 2598483004: Use TaskScheduler in EnsureProcessTerminated(). (Closed)
Patch Set: Use PostDelayedTaskWithTraits. Created 3 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 | « no previous file | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/kill.h" 5 #include "base/process/kill.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <io.h> 8 #include <io.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/process/memory.h" 18 #include "base/process/memory.h"
19 #include "base/process/process_iterator.h" 19 #include "base/process/process_iterator.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/task_scheduler/post_task.h"
21 #include "base/win/object_watcher.h" 21 #include "base/win/object_watcher.h"
22 22
23 namespace base { 23 namespace base {
24 24
25 namespace { 25 namespace {
26 26
27 // Exit codes with special meanings on Windows. 27 // Exit codes with special meanings on Windows.
28 const DWORD kNormalTerminationExitCode = 0; 28 const DWORD kNormalTerminationExitCode = 0;
29 const DWORD kDebuggerInactiveExitCode = 0xC0000354; 29 const DWORD kDebuggerInactiveExitCode = 0xC0000354;
30 const DWORD kKeyboardInterruptExitCode = 0xC000013A; 30 const DWORD kKeyboardInterruptExitCode = 0xC000013A;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (WaitForProcessesToExit(executable_name, wait, filter)) 189 if (WaitForProcessesToExit(executable_name, wait, filter))
190 return true; 190 return true;
191 KillProcesses(executable_name, exit_code, filter); 191 KillProcesses(executable_name, exit_code, filter);
192 return false; 192 return false;
193 } 193 }
194 194
195 void EnsureProcessTerminated(Process process) { 195 void EnsureProcessTerminated(Process process) {
196 DCHECK(!process.is_current()); 196 DCHECK(!process.is_current());
197 197
198 // If already signaled, then we are done! 198 // If already signaled, then we are done!
199 if (WaitForSingleObject(process.Handle(), 0) == WAIT_OBJECT_0) { 199 if (WaitForSingleObject(process.Handle(), 0) == WAIT_OBJECT_0)
200 return; 200 return;
201 }
202 201
203 ThreadTaskRunnerHandle::Get()->PostDelayedTask( 202 PostDelayedTaskWithTraits(
204 FROM_HERE, Bind(&TimerExpiredTask::TimedOut, 203 FROM_HERE,
205 Owned(new TimerExpiredTask(std::move(process)))), 204 TaskTraits()
gab 2017/01/09 17:36:38 TimerExpiredTask::watcher_::task_runner_ is set to
fdoray 2017/01/09 21:16:49 Done.
205 .WithPriority(TaskPriority::BACKGROUND)
206 .WithShutdownBehavior(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
207 Bind(&TimerExpiredTask::TimedOut,
208 Owned(new TimerExpiredTask(std::move(process)))),
gab 2017/01/09 17:36:38 Passed(MakeUnique(...)) instead of Owned(new ...)
fdoray 2017/01/09 21:16:49 n/a
206 TimeDelta::FromMilliseconds(kWaitInterval)); 209 TimeDelta::FromMilliseconds(kWaitInterval));
207 } 210 }
208 211
209 } // namespace base 212 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698