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

Unified Diff: remoting/host/worker_process_launcher_win.cc

Issue 9705065: Introducing the WorkerProcessLauncher class implementing the common logic for spawning a worker pro… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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
Index: remoting/host/worker_process_launcher_win.cc
diff --git a/remoting/host/worker_process_launcher_win.cc b/remoting/host/worker_process_launcher_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cd33e48cfe3c491f6655535d7e4acf98a4bd364f
--- /dev/null
+++ b/remoting/host/worker_process_launcher_win.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2012 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.
+//
+// This file implements the Windows service controlling Me2Me host processes
+// running within user sessions.
+
+#include "remoting/host/worker_process_launcher.h"
+
+#include <windows.h>
+
+#include "base/win/object_watcher.h"
+
+namespace {
+
+class WorkerProcessLauncherWin : public remoting::WorkerProcessLauncher,
+ public base::win::ObjectWatcher::Delegate {
+ public:
+ WorkerProcessLauncherWin(base::MessageLoopProxy* ipc_message_loop);
+ virtual ~WorkerProcessLauncherWin();
+
+ // base::win::ObjectWatcher::Delegate implementation.
+ virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
+
+ // WorkerProcessLauncher
+ virtual bool Start(IPC::Channel::Listener* listener,
+ const CreateChannelHandleCallback& create_channel_handle,
+ const LaunchWorkerCallback& launch_worker) OVERRIDE;
+ virtual void Stop() OVERRIDE;
+
+ private:
+ // Used to determine when the launched process terminates.
+ base::win::ObjectWatcher process_watcher_;
+};
+
+WorkerProcessLauncherWin::WorkerProcessLauncherWin(
+ base::MessageLoopProxy* ipc_message_loop)
+ : remoting::WorkerProcessLauncher(ipc_message_loop) {
+}
+
+WorkerProcessLauncherWin::~WorkerProcessLauncherWin() {
+ Stop();
+}
+
+void WorkerProcessLauncherWin::OnObjectSignaled(HANDLE object) {
+ DCHECK(process_watcher_.GetWatchedObject() == NULL);
+ OnChannelError();
+}
+
+bool WorkerProcessLauncherWin::Start(
+ IPC::Channel::Listener* listener,
+ const CreateChannelHandleCallback& create_channel_handle,
+ const LaunchWorkerCallback& launch_worker) {
+ if (WorkerProcessLauncher::Start(listener,
+ create_channel_handle,
+ launch_worker)) {
+ // Attach an object watcher to the returned process handle so that we get
+ // notified when the process terminates.
+ if (process_watcher_.StartWatching(get_process().handle(), this)) {
+ return true;
+ } else {
+ Stop();
+ }
+ }
+
+ return false;
+}
+
+void WorkerProcessLauncherWin::Stop() {
+ process_watcher_.StopWatching();
+ WorkerProcessLauncher::Stop();
+}
+
+} // namespace
+
+namespace remoting {
+
+// static
+scoped_ptr<WorkerProcessLauncher> WorkerProcessLauncher::Create(
+ base::MessageLoopProxy* ipc_message_loop) {
+ return scoped_ptr<WorkerProcessLauncher>(
+ new WorkerProcessLauncherWin(ipc_message_loop));
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698