| Index: base/win/process_monitor.h
|
| diff --git a/base/win/process_monitor.h b/base/win/process_monitor.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b0a832c3a76dd97cd126282e1d3a90f57ba0d2ee
|
| --- /dev/null
|
| +++ b/base/win/process_monitor.h
|
| @@ -0,0 +1,67 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef BASE_WIN_PROCESS_MONITOR_H_
|
| +#define BASE_WIN_PROCESS_MONITOR_H_
|
| +#pragma once
|
| +
|
| +#include <windows.h>
|
| +
|
| +#include "base/base_export.h"
|
| +#include "base/compiler_specific.h"
|
| +#include "base/callback.h"
|
| +#include "base/threading/platform_thread.h"
|
| +
|
| +namespace base {
|
| +class MessageLoopProxy;
|
| +}
|
| +
|
| +namespace base {
|
| +namespace win {
|
| +
|
| +// This class monitors a process handle (via a background thread) and runs a
|
| +// callback when that process and all other processes it has spawned
|
| +// have exited.
|
| +class BASE_EXPORT ProcessMonitor : public PlatformThread::Delegate {
|
| + public:
|
| + ProcessMonitor();
|
| + virtual ~ProcessMonitor();
|
| +
|
| + // Initializes the process monitoring.
|
| + // Parameters:
|
| + // process_handle
|
| + // Handle to the process which is to be added to the process monitoring job.
|
| + // callback
|
| + // The callback to be called when the process has finished.
|
| + // The callback will be called on the current thread.
|
| + void Initialize(HANDLE process_handle, const Closure& callback);
|
| +
|
| + // Stops the thread.
|
| + void Stop();
|
| +
|
| + private:
|
| + // PlatformThread::Delegate methods:
|
| + virtual void ThreadMain() OVERRIDE;
|
| +
|
| + PlatformThreadHandle thread_;
|
| +
|
| + // The monitoring job completion port. Created in Initialize.
|
| + HANDLE monitoring_job_completion_port_;
|
| + // Indicates that job monitoring is to be stopped
|
| + bool stop_job_monitoring_;
|
| + // The monitoring job. Should be created before the job monitor thread
|
| + // is started.
|
| + HANDLE monitoring_job_;
|
| +
|
| + // Callback when the process has finished.
|
| + Closure callback_;
|
| + scoped_refptr<MessageLoopProxy> callback_message_loop_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ProcessMonitor);
|
| +};
|
| +
|
| +} // namespace win
|
| +} // namespace base
|
| +
|
| +#endif // BASE_WIN_PROCESS_MONITOR_H_
|
|
|