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

Side by Side Diff: remoting/host/win/worker_process_launcher.h

Issue 10855249: [Chromoting] The daemon process now starts the networking process and passes the host configuration… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback and rebased on top of https://chromiumcodereview.appspot.com/10829467/ Created 8 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 5 #ifndef REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
6 #define REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 6 #define REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 10 matching lines...) Expand all
21 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
22 } // namespace base 22 } // namespace base
23 23
24 namespace IPC { 24 namespace IPC {
25 class ChannelProxy; 25 class ChannelProxy;
26 class Message; 26 class Message;
27 } // namespace IPC 27 } // namespace IPC
28 28
29 namespace remoting { 29 namespace remoting {
30 30
31 class WorkerProcessDelegate;
32
31 // Launches a worker process that is controlled via an IPC channel. All 33 // Launches a worker process that is controlled via an IPC channel. All
32 // interaction with the spawned process is through the IPC::Listener and Send() 34 // interaction with the spawned process is through the IPC::Listener and Send()
33 // method. In case of error the channel is closed and the worker process is 35 // method. In case of error the channel is closed and the worker process is
34 // terminated. 36 // terminated.
35 // 37 //
36 // WorkerProcessLauncher object is good for one process launch attempt only. 38 // WorkerProcessLauncher object is good for one process launch attempt only.
37 class WorkerProcessLauncher 39 class WorkerProcessLauncher
38 : public Stoppable, 40 : public Stoppable,
39 public base::win::ObjectWatcher::Delegate, 41 public base::win::ObjectWatcher::Delegate,
40 public IPC::Listener { 42 public IPC::Listener {
41 public: 43 public:
42 class Delegate { 44 class Delegate {
43 public: 45 public:
44 virtual ~Delegate(); 46 virtual ~Delegate();
45 47
46 // Starts the worker process and passes |channel_name| to it. 48 // Starts the worker process and passes |channel_name| to it.
47 // |process_exit_event_out| receives a handle that becomes signalled once 49 // |process_exit_event_out| receives a handle that becomes signalled once
48 // the launched process has been terminated. 50 // the launched process has been terminated.
49 virtual bool DoLaunchProcess( 51 virtual bool DoLaunchProcess(
50 const std::string& channel_name, 52 const std::string& channel_name,
51 base::win::ScopedHandle* process_exit_event_out) = 0; 53 base::win::ScopedHandle* process_exit_event_out) = 0;
52 54
53 // Terminates the worker process with the given exit code. 55 // Terminates the worker process with the given exit code.
54 virtual void DoKillProcess(DWORD exit_code) = 0; 56 virtual void DoKillProcess(DWORD exit_code) = 0;
55
56 // Notifies that a client has been connected to the channel.
57 virtual void OnChannelConnected() = 0;
58
59 // Processes messages sent by the client.
60 virtual bool OnMessageReceived(const IPC::Message& message) = 0;
61 }; 57 };
62 58
63 // Creates the launcher. 59 // Creates the launcher that will use |launcher_delegate| to manage the worker
64 // |delegate| will be able to receive messages sent over the channel once 60 // process and |worker_delegate| to handle IPCs.
65 // the worker has been started and until it is stopped by Stop() or an error
66 // occurs.
67 // 61 //
68 // |stopped_callback| and |main_task_runner| are passed to the underlying 62 // |stopped_callback| and |main_task_runner| are passed to the underlying
69 // |Stoppable| implementation. The caller should call all the methods on this 63 // |Stoppable| implementation. The caller should call all the methods on this
70 // class on the |main_task_runner| thread. |ipc_task_runner| is used to 64 // class on the |main_task_runner| thread. |ipc_task_runner| is used to
71 // perform background IPC I/O. 65 // perform background IPC I/O.
72 WorkerProcessLauncher( 66 WorkerProcessLauncher(
73 Delegate* delegate, 67 Delegate* launcher_delegate,
68 WorkerProcessDelegate* worker_delegate,
74 const base::Closure& stopped_callback, 69 const base::Closure& stopped_callback,
75 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 70 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
76 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner); 71 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner);
77 virtual ~WorkerProcessLauncher(); 72 virtual ~WorkerProcessLauncher();
78 73
79 // Starts the worker process. 74 // Starts the worker process.
80 void Start(const std::string& pipe_sddl); 75 void Start(const std::string& pipe_sddl);
81 76
82 // Sends an IPC message to the worker process. This method can be called only 77 // Sends an IPC message to the worker process. The message will be silently
83 // after successful Start() and until Stop() is called or an error occurred. 78 // dropped if Send() is called before Start() or after stutdown has been
79 // initiated.
84 void Send(IPC::Message* message); 80 void Send(IPC::Message* message);
85 81
86 // base::win::ObjectWatcher::Delegate implementation. 82 // base::win::ObjectWatcher::Delegate implementation.
87 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; 83 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
88 84
89 // IPC::Listener implementation. 85 // IPC::Listener implementation.
90 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 86 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
91 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 87 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
92 virtual void OnChannelError() OVERRIDE; 88 virtual void OnChannelError() OVERRIDE;
93 89
94 protected: 90 protected:
95 // Stoppable implementation. 91 // Stoppable implementation.
96 virtual void DoStop() OVERRIDE; 92 virtual void DoStop() OVERRIDE;
97 93
98 private: 94 private:
99 // Creates the server end of the Chromoting IPC channel. 95 // Creates the server end of the Chromoting IPC channel.
100 bool CreatePipeForIpcChannel(const std::string& channel_name, 96 bool CreatePipeForIpcChannel(const std::string& channel_name,
101 const std::string& pipe_sddl, 97 const std::string& pipe_sddl,
102 base::win::ScopedHandle* pipe_out); 98 base::win::ScopedHandle* pipe_out);
103 99
104 // Generates random channel ID. 100 // Generates random channel ID.
105 std::string GenerateRandomChannelId(); 101 std::string GenerateRandomChannelId();
106 102
107 Delegate* delegate_; 103 Delegate* launcher_delegate_;
104 WorkerProcessDelegate* worker_delegate_;
108 105
109 // The main service message loop. 106 // The main service message loop.
110 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 107 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
111 108
112 // Message loop used by the IPC channel. 109 // Message loop used by the IPC channel.
113 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; 110 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
114 111
115 // Used to determine when the launched process terminates. 112 // Used to determine when the launched process terminates.
116 base::win::ObjectWatcher process_watcher_; 113 base::win::ObjectWatcher process_watcher_;
117 114
118 // A waiting handle that becomes signalled once the launched process has 115 // A waiting handle that becomes signalled once the launched process has
119 // been terminated. 116 // been terminated.
120 base::win::ScopedHandle process_exit_event_; 117 base::win::ScopedHandle process_exit_event_;
121 118
122 // The IPC channel connecting to the launched process. 119 // The IPC channel connecting to the launched process.
123 scoped_ptr<IPC::ChannelProxy> ipc_channel_; 120 scoped_ptr<IPC::ChannelProxy> ipc_channel_;
124 121
125 // The server end of the pipe. 122 // The server end of the pipe.
126 base::win::ScopedHandle pipe_; 123 base::win::ScopedHandle pipe_;
127 124
128 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); 125 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher);
129 }; 126 };
130 127
131 } // namespace remoting 128 } // namespace remoting
132 129
133 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 130 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698