| OLD | NEW |
| 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 #ifndef CHROME_COMMON_PROCESS_WATCHER_H_ | 5 #ifndef CHROME_COMMON_PROCESS_WATCHER_H_ |
| 6 #define CHROME_COMMON_PROCESS_WATCHER_H_ | 6 #define CHROME_COMMON_PROCESS_WATCHER_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 | 12 |
| 13 class ProcessWatcher { | 13 class ProcessWatcher { |
| 14 public: | 14 public: |
| 15 // This method ensures that the specified process eventually terminates, and | 15 // This method ensures that the specified process eventually terminates, and |
| 16 // then it closes the given process handle. | 16 // then it closes the given process handle. |
| 17 // | 17 // |
| 18 // It assumes that the process has already been signalled to exit, and it | 18 // It assumes that the process has already been signalled to exit, and it |
| 19 // begins by waiting a small amount of time for it to exit. If the process | 19 // begins by waiting a small amount of time for it to exit. If the process |
| 20 // does not appear to have exited, then this function starts to become | 20 // does not appear to have exited, then this function starts to become |
| 21 // aggressive about ensuring that the process terminates. | 21 // aggressive about ensuring that the process terminates. |
| 22 // | 22 // |
| 23 // This method does not block the calling thread. | 23 // On Linux this method does not block the calling thread. |
| 24 // On OS X this method may block for up to 2 seconds. |
| 24 // | 25 // |
| 25 // NOTE: The process handle must have been opened with the PROCESS_TERMINATE | 26 // NOTE: The process handle must have been opened with the PROCESS_TERMINATE |
| 26 // and SYNCHRONIZE permissions. | 27 // and SYNCHRONIZE permissions. |
| 27 // | 28 // |
| 28 static void EnsureProcessTerminated(base::ProcessHandle process_handle); | 29 static void EnsureProcessTerminated(base::ProcessHandle process_handle); |
| 29 | 30 |
| 30 #if defined(OS_POSIX) | 31 #if defined(OS_LINUX) |
| 31 // The nicer version of EnsureProcessTerminated() that is patient and will | 32 // The nicer version of EnsureProcessTerminated() that is patient and will |
| 32 // wait for |process_handle| to finish and then reap it. | 33 // wait for |process_handle| to finish and then reap it. |
| 33 static void EnsureProcessGetsReaped(base::ProcessHandle process_handle); | 34 static void EnsureProcessGetsReaped(base::ProcessHandle process_handle); |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 // Do not instantiate this class. | 38 // Do not instantiate this class. |
| 38 ProcessWatcher(); | 39 ProcessWatcher(); |
| 39 | 40 |
| 40 DISALLOW_COPY_AND_ASSIGN(ProcessWatcher); | 41 DISALLOW_COPY_AND_ASSIGN(ProcessWatcher); |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 #endif // CHROME_COMMON_PROCESS_WATCHER_H_ | 44 #endif // CHROME_COMMON_PROCESS_WATCHER_H_ |
| OLD | NEW |