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

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: Added missing signal.h Created 8 years, 3 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
« no previous file with comments | « remoting/host/win/host_service.cc ('k') | remoting/host/win/worker_process_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
22 class SingleThreadTaskRunner; 22 class SingleThreadTaskRunner;
23 } // namespace base 23 } // namespace base
24 24
25 namespace IPC { 25 namespace IPC {
26 class ChannelProxy; 26 class ChannelProxy;
27 class Message; 27 class Message;
28 } // namespace IPC 28 } // namespace IPC
29 29
30 namespace remoting { 30 namespace remoting {
31 31
32 class WorkerProcessIpcDelegate;
33
32 // Launches a worker process that is controlled via an IPC channel. All 34 // Launches a worker process that is controlled via an IPC channel. All
33 // interaction with the spawned process is through the IPC::Listener and Send() 35 // interaction with the spawned process is through the IPC::Listener and Send()
34 // method. In case of error the channel is closed and the worker process is 36 // method. In case of error the channel is closed and the worker process is
35 // terminated. 37 // terminated.
36 // 38 //
37 // WorkerProcessLauncher object is good for one process launch attempt only. 39 // WorkerProcessLauncher object is good for one process launch attempt only.
38 class WorkerProcessLauncher 40 class WorkerProcessLauncher
39 : public Stoppable, 41 : public Stoppable,
40 public base::win::ObjectWatcher::Delegate, 42 public base::win::ObjectWatcher::Delegate,
41 public IPC::Listener { 43 public IPC::Listener {
42 public: 44 public:
43 class Delegate { 45 class Delegate {
44 public: 46 public:
45 virtual ~Delegate(); 47 virtual ~Delegate();
46 48
47 // Starts the worker process and passes |channel_name| to it. 49 // Starts the worker process and passes |channel_name| to it.
48 // |process_exit_event_out| receives a handle that becomes signalled once 50 // |process_exit_event_out| receives a handle that becomes signalled once
49 // the launched process has been terminated. 51 // the launched process has been terminated.
50 virtual bool DoLaunchProcess( 52 virtual bool DoLaunchProcess(
51 const std::string& channel_name, 53 const std::string& channel_name,
52 base::win::ScopedHandle* process_exit_event_out) = 0; 54 base::win::ScopedHandle* process_exit_event_out) = 0;
53 55
54 // Terminates the worker process with the given exit code. 56 // Terminates the worker process with the given exit code.
55 virtual void DoKillProcess(DWORD exit_code) = 0; 57 virtual void DoKillProcess(DWORD exit_code) = 0;
56
57 // Notifies that a client has been connected to the channel.
58 virtual void OnChannelConnected() = 0;
59
60 // Processes messages sent by the client.
61 virtual bool OnMessageReceived(const IPC::Message& message) = 0;
62 }; 58 };
63 59
64 // Creates the launcher. 60 // Creates the launcher that will use |launcher_delegate| to manage the worker
65 // |delegate| will be able to receive messages sent over the channel once 61 // process and |worker_delegate| to handle IPCs.
66 // the worker has been started and until it is stopped by Stop() or an error
67 // occurs.
68 // 62 //
69 // |stopped_callback| and |main_task_runner| are passed to the underlying 63 // |stopped_callback| and |main_task_runner| are passed to the underlying
70 // |Stoppable| implementation. The caller should call all the methods on this 64 // |Stoppable| implementation. The caller should call all the methods on this
71 // class on the |main_task_runner| thread. |ipc_task_runner| is used to 65 // class on the |main_task_runner| thread. |ipc_task_runner| is used to
72 // perform background IPC I/O. 66 // perform background IPC I/O.
73 WorkerProcessLauncher( 67 WorkerProcessLauncher(
74 Delegate* delegate, 68 Delegate* launcher_delegate,
69 WorkerProcessIpcDelegate* worker_delegate,
75 const base::Closure& stopped_callback, 70 const base::Closure& stopped_callback,
76 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 71 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
77 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner); 72 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner);
78 virtual ~WorkerProcessLauncher(); 73 virtual ~WorkerProcessLauncher();
79 74
80 // Starts the worker process. 75 // Starts the worker process.
81 void Start(const std::string& pipe_sddl); 76 void Start(const std::string& pipe_sddl);
82 77
83 // Sends an IPC message to the worker process. This method can be called only 78 // Sends an IPC message to the worker process. The message will be silently
84 // after successful Start() and until Stop() is called or an error occurred. 79 // dropped if Send() is called before Start() or after stutdown has been
80 // initiated.
85 void Send(IPC::Message* message); 81 void Send(IPC::Message* message);
86 82
87 // base::win::ObjectWatcher::Delegate implementation. 83 // base::win::ObjectWatcher::Delegate implementation.
88 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; 84 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
89 85
90 // IPC::Listener implementation. 86 // IPC::Listener implementation.
91 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 87 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
92 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 88 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
93 virtual void OnChannelError() OVERRIDE; 89 virtual void OnChannelError() OVERRIDE;
94 90
95 protected: 91 protected:
96 // Stoppable implementation. 92 // Stoppable implementation.
97 virtual void DoStop() OVERRIDE; 93 virtual void DoStop() OVERRIDE;
98 94
99 private: 95 private:
100 // Creates the server end of the Chromoting IPC channel. 96 // Creates the server end of the Chromoting IPC channel.
101 bool CreatePipeForIpcChannel(const std::string& channel_name, 97 bool CreatePipeForIpcChannel(const std::string& channel_name,
102 const std::string& pipe_sddl, 98 const std::string& pipe_sddl,
103 base::win::ScopedHandle* pipe_out); 99 base::win::ScopedHandle* pipe_out);
104 100
105 // Generates random channel ID. 101 // Generates random channel ID.
106 std::string GenerateRandomChannelId(); 102 std::string GenerateRandomChannelId();
107 103
108 Delegate* delegate_; 104 Delegate* launcher_delegate_;
105 WorkerProcessIpcDelegate* worker_delegate_;
109 106
110 // The main service message loop. 107 // The main service message loop.
111 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 108 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
112 109
113 // Message loop used by the IPC channel. 110 // Message loop used by the IPC channel.
114 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; 111 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
115 112
116 // Used to determine when the launched process terminates. 113 // Used to determine when the launched process terminates.
117 base::win::ObjectWatcher process_watcher_; 114 base::win::ObjectWatcher process_watcher_;
118 115
(...skipping 10 matching lines...) Expand all
129 126
130 // The server end of the pipe. 127 // The server end of the pipe.
131 base::win::ScopedHandle pipe_; 128 base::win::ScopedHandle pipe_;
132 129
133 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); 130 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher);
134 }; 131 };
135 132
136 } // namespace remoting 133 } // namespace remoting
137 134
138 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 135 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
OLDNEW
« no previous file with comments | « remoting/host/win/host_service.cc ('k') | remoting/host/win/worker_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698