| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_WIN_PROCESS_MONITOR_H_ |
| 6 #define BASE_WIN_PROCESS_MONITOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <windows.h> |
| 10 |
| 11 #include "base/base_export.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/callback.h" |
| 14 #include "base/threading/platform_thread.h" |
| 15 |
| 16 namespace base { |
| 17 class MessageLoopProxy; |
| 18 } |
| 19 |
| 20 namespace base { |
| 21 namespace win { |
| 22 |
| 23 // This class monitors a process handle (via a background thread) and runs a |
| 24 // callback when that process and all other processes it has spawned |
| 25 // have exited. |
| 26 class BASE_EXPORT ProcessMonitor : public PlatformThread::Delegate { |
| 27 public: |
| 28 ProcessMonitor(); |
| 29 virtual ~ProcessMonitor(); |
| 30 |
| 31 // Initializes the process monitoring. |
| 32 // Parameters: |
| 33 // process_handle |
| 34 // Handle to the process which is to be added to the process monitoring job. |
| 35 // callback |
| 36 // The callback to be called when the process has finished. |
| 37 // The callback will be called on the current thread. |
| 38 void Initialize(HANDLE process_handle, const Closure& callback); |
| 39 |
| 40 // Stops the thread. |
| 41 void Stop(); |
| 42 |
| 43 private: |
| 44 // PlatformThread::Delegate methods: |
| 45 virtual void ThreadMain() OVERRIDE; |
| 46 |
| 47 PlatformThreadHandle thread_; |
| 48 |
| 49 // The monitoring job completion port. Created in Initialize. |
| 50 HANDLE monitoring_job_completion_port_; |
| 51 // Indicates that job monitoring is to be stopped |
| 52 bool stop_job_monitoring_; |
| 53 // The monitoring job. Should be created before the job monitor thread |
| 54 // is started. |
| 55 HANDLE monitoring_job_; |
| 56 |
| 57 // Callback when the process has finished. |
| 58 Closure callback_; |
| 59 scoped_refptr<MessageLoopProxy> callback_message_loop_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(ProcessMonitor); |
| 62 }; |
| 63 |
| 64 } // namespace win |
| 65 } // namespace base |
| 66 |
| 67 #endif // BASE_WIN_PROCESS_MONITOR_H_ |
| OLD | NEW |