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

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

Issue 11118005: Pass the client end handle of the network-to-daemon IPC channel via handle inheritance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 years, 2 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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/win/scoped_handle.h" 12 #include "base/win/scoped_handle.h"
13 #include "ipc/ipc_sender.h"
13 14
14 namespace base { 15 namespace base {
15 class SingleThreadTaskRunner; 16 class SingleThreadTaskRunner;
16 } // namespace base 17 } // namespace base
17 18
18 namespace IPC { 19 namespace IPC {
20 class Listener;
19 class Message; 21 class Message;
20 } // namespace IPC 22 } // namespace IPC
21 23
22 namespace remoting { 24 namespace remoting {
23 25
24 class WorkerProcessIpcDelegate; 26 class WorkerProcessIpcDelegate;
25 27
26 // Launches a worker process that is controlled via an IPC channel. All 28 // Launches a worker process that is controlled via an IPC channel. All
27 // interaction with the spawned process is through WorkerProcessIpcDelegate and 29 // interaction with the spawned process is through WorkerProcessIpcDelegate and
28 // Send() method. In case of error the channel is closed and the worker process 30 // Send() method. In case of error the channel is closed and the worker process
29 // is terminated. 31 // is terminated.
30 class WorkerProcessLauncher { 32 class WorkerProcessLauncher {
31 public: 33 public:
32 class Delegate { 34 class Delegate : public IPC::Sender {
33 public: 35 public:
34 virtual ~Delegate(); 36 virtual ~Delegate();
35 37
36 // Returns the exit code of the worker process. 38 // Returns the exit code of the worker process.
37 virtual DWORD GetExitCode() = 0; 39 virtual DWORD GetExitCode() = 0;
38 40
39 // Terminates the worker process with the given exit code. 41 // Terminates the worker process with the given exit code. Destroys the IPC
42 // channel created by LaunchProcess().
40 virtual void KillProcess(DWORD exit_code) = 0; 43 virtual void KillProcess(DWORD exit_code) = 0;
41 44
42 // Starts the worker process and passes |channel_name| to it. 45 // Starts the worker process and creates an IPC channel it can connect to.
43 // |process_exit_event_out| receives a handle that becomes signalled once 46 // |delegate| specifies the object that will receive notifications from
44 // the launched process has been terminated. 47 // the IPC channel. |process_exit_event_out| receives a handle that becomes
48 // signalled once the launched process has been terminated.
45 virtual bool LaunchProcess( 49 virtual bool LaunchProcess(
46 const std::string& channel_name, 50 IPC::Listener* delegate,
47 base::win::ScopedHandle* process_exit_event_out) = 0; 51 base::win::ScopedHandle* process_exit_event_out) = 0;
48 }; 52 };
49 53
50 // Creates the launcher that will use |launcher_delegate| to manage the worker 54 // Creates the launcher that will use |launcher_delegate| to manage the worker
51 // process and |worker_delegate| to handle IPCs. The caller must ensure that 55 // process and |worker_delegate| to handle IPCs. The caller must ensure that
52 // |worker_delegate| remains valid until Stoppable::Stop() method has been 56 // |worker_delegate| remains valid until Stoppable::Stop() method has been
53 // called. 57 // called.
54 // 58 //
55 // The caller should call all the methods on this class on 59 // The caller should call all the methods on this class on
56 // the |caller_task_runner| thread. Methods of both delegate interfaces are 60 // the |caller_task_runner| thread. Methods of both delegate interfaces are
57 // called on the |caller_task_runner| thread as well. |io_task_runner| is used 61 // called on the |caller_task_runner| thread as well.
58 // to perform background IPC I/O.
59 WorkerProcessLauncher( 62 WorkerProcessLauncher(
60 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 63 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
61 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
62 scoped_ptr<Delegate> launcher_delegate, 64 scoped_ptr<Delegate> launcher_delegate,
63 WorkerProcessIpcDelegate* worker_delegate, 65 WorkerProcessIpcDelegate* worker_delegate);
64 const std::string& pipe_security_descriptor);
65 ~WorkerProcessLauncher(); 66 ~WorkerProcessLauncher();
66 67
67 // Sends an IPC message to the worker process. The message will be silently 68 // Sends an IPC message to the worker process. The message will be silently
68 // dropped if Send() is called before Start() or after stutdown has been 69 // dropped if Send() is called before Start() or after stutdown has been
69 // initiated. 70 // initiated.
70 void Send(IPC::Message* message); 71 void Send(IPC::Message* message);
71 72
72 private: 73 private:
73 // The actual implementation resides in WorkerProcessLauncher::Core class. 74 // The actual implementation resides in WorkerProcessLauncher::Core class.
74 class Core; 75 class Core;
75 scoped_refptr<Core> core_; 76 scoped_refptr<Core> core_;
76 77
77 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); 78 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher);
78 }; 79 };
79 80
80 } // namespace remoting 81 } // namespace remoting
81 82
82 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 83 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
OLDNEW
« no previous file with comments | « remoting/host/win/unprivileged_process_delegate.cc ('k') | remoting/host/win/worker_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698