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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 // This file implements the Windows service controlling Me2Me host processes
6 // running within user sessions.
7
8 #include "remoting/host/worker_process_launcher.h"
9
10 #include <windows.h>
11
12 #include "base/win/object_watcher.h"
13
14 namespace {
15
16 class WorkerProcessLauncherWin : public remoting::WorkerProcessLauncher,
17 public base::win::ObjectWatcher::Delegate {
18 public:
19 WorkerProcessLauncherWin(base::MessageLoopProxy* ipc_message_loop);
20 virtual ~WorkerProcessLauncherWin();
21
22 // base::win::ObjectWatcher::Delegate implementation.
23 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
24
25 // WorkerProcessLauncher
26 virtual bool Start(IPC::Channel::Listener* listener,
27 const CreateChannelHandleCallback& create_channel_handle,
28 const LaunchWorkerCallback& launch_worker) OVERRIDE;
29 virtual void Stop() OVERRIDE;
30
31 private:
32 // Used to determine when the launched process terminates.
33 base::win::ObjectWatcher process_watcher_;
34 };
35
36 WorkerProcessLauncherWin::WorkerProcessLauncherWin(
37 base::MessageLoopProxy* ipc_message_loop)
38 : remoting::WorkerProcessLauncher(ipc_message_loop) {
39 }
40
41 WorkerProcessLauncherWin::~WorkerProcessLauncherWin() {
42 Stop();
43 }
44
45 void WorkerProcessLauncherWin::OnObjectSignaled(HANDLE object) {
46 DCHECK(process_watcher_.GetWatchedObject() == NULL);
47 OnChannelError();
48 }
49
50 bool WorkerProcessLauncherWin::Start(
51 IPC::Channel::Listener* listener,
52 const CreateChannelHandleCallback& create_channel_handle,
53 const LaunchWorkerCallback& launch_worker) {
54 if (WorkerProcessLauncher::Start(listener,
55 create_channel_handle,
56 launch_worker)) {
57 // Attach an object watcher to the returned process handle so that we get
58 // notified when the process terminates.
59 if (process_watcher_.StartWatching(get_process().handle(), this)) {
60 return true;
61 } else {
62 Stop();
63 }
64 }
65
66 return false;
67 }
68
69 void WorkerProcessLauncherWin::Stop() {
70 process_watcher_.StopWatching();
71 WorkerProcessLauncher::Stop();
72 }
73
74 } // namespace
75
76 namespace remoting {
77
78 // static
79 scoped_ptr<WorkerProcessLauncher> WorkerProcessLauncher::Create(
80 base::MessageLoopProxy* ipc_message_loop) {
81 return scoped_ptr<WorkerProcessLauncher>(
82 new WorkerProcessLauncherWin(ipc_message_loop));
83 }
84
85 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698