|
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 |
|
3 // found in the LICENSE file. |
|
4 |
|
5 #ifndef CHROME_COMMON_PROCESS_WATCHER_H_ |
|
6 #define CHROME_COMMON_PROCESS_WATCHER_H_ |
|
7 |
|
8 #include "base/basictypes.h" |
|
9 #include "base/process_util.h" |
|
10 |
|
11 class ProcessWatcher { |
|
12 public: |
|
13 // This method ensures that the specified process eventually terminates, and |
|
14 // then it closes the given process handle. |
|
15 // |
|
16 // It assumes that the process has already been signalled to exit, and it |
|
17 // begins by waiting a small amount of time for it to exit. If the process |
|
18 // does not appear to have exited, then this function starts to become |
|
19 // aggressive about ensuring that the process terminates. |
|
20 // |
|
21 // This method does not block the calling thread. |
|
22 // |
|
23 // NOTE: The process handle must have been opened with the PROCESS_TERMINATE |
|
24 // and SYNCHRONIZE permissions. |
|
25 // |
|
26 static void EnsureProcessTerminated(base::ProcessHandle process_handle |
|
27 , bool force=true |
|
28 ); |
|
29 |
|
30 private: |
|
31 // Do not instantiate this class. |
|
32 ProcessWatcher(); |
|
33 |
|
34 DISALLOW_COPY_AND_ASSIGN(ProcessWatcher); |
|
35 }; |
|
36 |
|
37 #endif // CHROME_COMMON_PROCESS_WATCHER_H_ |