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

Unified Diff: base/win/process_monitor.h

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/values.cc ('k') | base/win/process_monitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « base/values.cc ('k') | base/win/process_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698