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

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: 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 outsources specific of launching the worker to
Wez 2012/08/21 00:18:57 nit: I think you mean you're creating a launcher t
alexeypa (please no reviews) 2012/08/23 23:53:01 Done.
64 // |delegate| will be able to receive messages sent over the channel once 60 // |launcher_delegate|. |worker_delegate| will be able to receive messages
65 // the worker has been started and until it is stopped by Stop() or an error 61 // sent over the channel once the worker has been started and until it is
66 // occurs. 62 // stopped by Stop() or an error occurs.
67 // 63 //
68 // |stopped_callback| and |main_task_runner| are passed to the underlying 64 // |stopped_callback| and |main_task_runner| are passed to the underlying
69 // |Stoppable| implementation. The caller should call all the methods on this 65 // |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 66 // class on the |main_task_runner| thread. |ipc_task_runner| is used to
71 // perform background IPC I/O. 67 // perform background IPC I/O.
72 WorkerProcessLauncher( 68 WorkerProcessLauncher(
73 Delegate* delegate, 69 Delegate* launcher_delegate,
70 WorkerProcessDelegate* worker_delegate,
Wez 2012/08/21 00:18:57 Why do we not just use IPC::Listener here?
alexeypa (please no reviews) 2012/08/21 17:16:36 Because IPC::Listener is a different interface. IP
Wez 2012/08/24 22:20:37 IPC::Listener just has OnMessageReceived, OnChanne
alexeypa (please no reviews) 2012/08/27 23:16:41 Yes, IPC::Listener is very similar but different i
Wez 2012/08/30 20:36:04 The advantage is simply that we don't define a new
alexeypa (please no reviews) 2012/08/30 23:15:13 It provides different functionality, that is not a
Wez 2012/08/31 00:23:04 Those are all optional for the IPC::Listener imple
alexeypa (please no reviews) 2012/08/31 21:26:55 Implemented may mistakenly assume that the optiona
74 const base::Closure& stopped_callback, 71 const base::Closure& stopped_callback,
75 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 72 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
76 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner); 73 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner);
77 virtual ~WorkerProcessLauncher(); 74 virtual ~WorkerProcessLauncher();
78 75
79 // Starts the worker process. 76 // Starts the worker process.
80 void Start(const std::string& pipe_sddl); 77 void Start(const std::string& pipe_sddl);
81 78
82 // Sends an IPC message to the worker process. This method can be called only 79 // 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. 80 // dropped if Send() is called before Start() or after stutdown has been
81 // initiated.
84 void Send(IPC::Message* message); 82 void Send(IPC::Message* message);
85 83
86 // base::win::ObjectWatcher::Delegate implementation. 84 // base::win::ObjectWatcher::Delegate implementation.
87 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; 85 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
88 86
89 // IPC::Listener implementation. 87 // IPC::Listener implementation.
90 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
91 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 89 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
92 virtual void OnChannelError() OVERRIDE; 90 virtual void OnChannelError() OVERRIDE;
93 91
94 protected: 92 protected:
95 // Stoppable implementation. 93 // Stoppable implementation.
96 virtual void DoStop() OVERRIDE; 94 virtual void DoStop() OVERRIDE;
97 95
98 private: 96 private:
99 // Creates the server end of the Chromoting IPC channel. 97 // Creates the server end of the Chromoting IPC channel.
100 bool CreatePipeForIpcChannel(const std::string& channel_name, 98 bool CreatePipeForIpcChannel(const std::string& channel_name,
101 const std::string& pipe_sddl, 99 const std::string& pipe_sddl,
102 base::win::ScopedHandle* pipe_out); 100 base::win::ScopedHandle* pipe_out);
103 101
104 // Generates random channel ID. 102 // Generates random channel ID.
105 std::string GenerateRandomChannelId(); 103 std::string GenerateRandomChannelId();
106 104
107 Delegate* delegate_; 105 Delegate* launcher_delegate_;
106 WorkerProcessDelegate* worker_delegate_;
108 107
109 // The main service message loop. 108 // The main service message loop.
110 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 109 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
111 110
112 // Message loop used by the IPC channel. 111 // Message loop used by the IPC channel.
113 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; 112 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
114 113
115 // Used to determine when the launched process terminates. 114 // Used to determine when the launched process terminates.
116 base::win::ObjectWatcher process_watcher_; 115 base::win::ObjectWatcher process_watcher_;
117 116
118 // A waiting handle that becomes signalled once the launched process has 117 // A waiting handle that becomes signalled once the launched process has
119 // been terminated. 118 // been terminated.
120 base::win::ScopedHandle process_exit_event_; 119 base::win::ScopedHandle process_exit_event_;
121 120
122 // The IPC channel connecting to the launched process. 121 // The IPC channel connecting to the launched process.
123 scoped_ptr<IPC::ChannelProxy> ipc_channel_; 122 scoped_ptr<IPC::ChannelProxy> ipc_channel_;
124 123
125 // The server end of the pipe. 124 // The server end of the pipe.
126 base::win::ScopedHandle pipe_; 125 base::win::ScopedHandle pipe_;
127 126
128 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); 127 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher);
129 }; 128 };
130 129
131 } // namespace remoting 130 } // namespace remoting
132 131
133 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 132 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698