OLD | NEW |
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 // This file implements the Windows service controlling Me2Me host processes | 5 // This file implements the Windows service controlling Me2Me host processes |
6 // running within user sessions. | 6 // running within user sessions. |
7 | 7 |
8 #include "remoting/host/win/wts_session_process_delegate.h" | 8 #include "remoting/host/win/wts_session_process_delegate.h" |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // asynchronous fire-and-forget shutdown. | 49 // asynchronous fire-and-forget shutdown. |
50 class WtsSessionProcessDelegate::Core | 50 class WtsSessionProcessDelegate::Core |
51 : public base::RefCountedThreadSafe<WtsSessionProcessDelegate::Core>, | 51 : public base::RefCountedThreadSafe<WtsSessionProcessDelegate::Core>, |
52 public base::MessagePumpForIO::IOHandler, | 52 public base::MessagePumpForIO::IOHandler, |
53 public WorkerProcessLauncher::Delegate { | 53 public WorkerProcessLauncher::Delegate { |
54 public: | 54 public: |
55 // The caller must ensure that |delegate| remains valid at least until | 55 // The caller must ensure that |delegate| remains valid at least until |
56 // Stop() method has been called. | 56 // Stop() method has been called. |
57 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 57 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
58 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 58 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
59 const FilePath& binary_path, | 59 const base::FilePath& binary_path, |
60 bool launch_elevated, | 60 bool launch_elevated, |
61 const std::string& channel_security); | 61 const std::string& channel_security); |
62 | 62 |
63 // base::MessagePumpForIO::IOHandler implementation. | 63 // base::MessagePumpForIO::IOHandler implementation. |
64 virtual void OnIOCompleted(base::MessagePumpForIO::IOContext* context, | 64 virtual void OnIOCompleted(base::MessagePumpForIO::IOContext* context, |
65 DWORD bytes_transferred, | 65 DWORD bytes_transferred, |
66 DWORD error) OVERRIDE; | 66 DWORD error) OVERRIDE; |
67 | 67 |
68 // IPC::Sender implementation. | 68 // IPC::Sender implementation. |
69 virtual bool Send(IPC::Message* message) OVERRIDE; | 69 virtual bool Send(IPC::Message* message) OVERRIDE; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Called to process incoming job object notifications. | 103 // Called to process incoming job object notifications. |
104 void OnJobNotification(DWORD message, DWORD pid); | 104 void OnJobNotification(DWORD message, DWORD pid); |
105 | 105 |
106 // The task runner all public methods of this class should be called on. | 106 // The task runner all public methods of this class should be called on. |
107 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 107 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
108 | 108 |
109 // The task runner serving job object notifications. | 109 // The task runner serving job object notifications. |
110 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 110 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
111 | 111 |
112 // Path to the worker process binary. | 112 // Path to the worker process binary. |
113 FilePath binary_path_; | 113 base::FilePath binary_path_; |
114 | 114 |
115 // The server end of the IPC channel used to communicate to the worker | 115 // The server end of the IPC channel used to communicate to the worker |
116 // process. | 116 // process. |
117 scoped_ptr<IPC::ChannelProxy> channel_; | 117 scoped_ptr<IPC::ChannelProxy> channel_; |
118 | 118 |
119 // Security descriptor (as SDDL) to be applied to |channel_|. | 119 // Security descriptor (as SDDL) to be applied to |channel_|. |
120 std::string channel_security_; | 120 std::string channel_security_; |
121 | 121 |
122 // Pointer to GetNamedPipeClientProcessId() API if it is available. | 122 // Pointer to GetNamedPipeClientProcessId() API if it is available. |
123 typedef BOOL (WINAPI * GetNamedPipeClientProcessIdFn)(HANDLE, DWORD*); | 123 typedef BOOL (WINAPI * GetNamedPipeClientProcessIdFn)(HANDLE, DWORD*); |
(...skipping 20 matching lines...) Expand all Loading... |
144 | 144 |
145 // The handle of the worker process, if launched. | 145 // The handle of the worker process, if launched. |
146 base::win::ScopedHandle worker_process_; | 146 base::win::ScopedHandle worker_process_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(Core); | 148 DISALLOW_COPY_AND_ASSIGN(Core); |
149 }; | 149 }; |
150 | 150 |
151 WtsSessionProcessDelegate::Core::Core( | 151 WtsSessionProcessDelegate::Core::Core( |
152 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 152 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
153 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 153 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
154 const FilePath& binary_path, | 154 const base::FilePath& binary_path, |
155 bool launch_elevated, | 155 bool launch_elevated, |
156 const std::string& channel_security) | 156 const std::string& channel_security) |
157 : main_task_runner_(main_task_runner), | 157 : main_task_runner_(main_task_runner), |
158 io_task_runner_(io_task_runner), | 158 io_task_runner_(io_task_runner), |
159 binary_path_(binary_path), | 159 binary_path_(binary_path), |
160 channel_security_(channel_security), | 160 channel_security_(channel_security), |
161 get_named_pipe_client_pid_(NULL), | 161 get_named_pipe_client_pid_(NULL), |
162 launch_elevated_(launch_elevated), | 162 launch_elevated_(launch_elevated), |
163 stopping_(false) { | 163 stopping_(false) { |
164 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 164 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 242 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
243 | 243 |
244 CommandLine command_line(CommandLine::NO_PROGRAM); | 244 CommandLine command_line(CommandLine::NO_PROGRAM); |
245 if (launch_elevated_) { | 245 if (launch_elevated_) { |
246 // The job object is not ready. Retry starting the host process later. | 246 // The job object is not ready. Retry starting the host process later. |
247 if (!job_.IsValid()) { | 247 if (!job_.IsValid()) { |
248 return false; | 248 return false; |
249 } | 249 } |
250 | 250 |
251 // Construct the helper binary name. | 251 // Construct the helper binary name. |
252 FilePath daemon_binary; | 252 base::FilePath daemon_binary; |
253 if (!GetInstalledBinaryPath(kDaemonBinaryName, &daemon_binary)) | 253 if (!GetInstalledBinaryPath(kDaemonBinaryName, &daemon_binary)) |
254 return false; | 254 return false; |
255 | 255 |
256 // Create the command line passing the name of the IPC channel to use and | 256 // Create the command line passing the name of the IPC channel to use and |
257 // copying known switches from the caller's command line. | 257 // copying known switches from the caller's command line. |
258 command_line.SetProgram(daemon_binary); | 258 command_line.SetProgram(daemon_binary); |
259 command_line.AppendSwitchPath(kElevateSwitchName, binary_path_); | 259 command_line.AppendSwitchPath(kElevateSwitchName, binary_path_); |
260 | 260 |
261 CHECK(ResetEvent(process_exit_event_)); | 261 CHECK(ResetEvent(process_exit_event_)); |
262 } else { | 262 } else { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // if we cannot get the actual exit code. So here we can safely ignore | 478 // if we cannot get the actual exit code. So here we can safely ignore |
479 // the error returned by OpenProcess(). | 479 // the error returned by OpenProcess(). |
480 worker_process_.Set(OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)); | 480 worker_process_.Set(OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)); |
481 break; | 481 break; |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 WtsSessionProcessDelegate::WtsSessionProcessDelegate( | 485 WtsSessionProcessDelegate::WtsSessionProcessDelegate( |
486 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 486 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
487 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 487 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
488 const FilePath& binary_path, | 488 const base::FilePath& binary_path, |
489 uint32 session_id, | 489 uint32 session_id, |
490 bool launch_elevated, | 490 bool launch_elevated, |
491 const std::string& channel_security) { | 491 const std::string& channel_security) { |
492 core_ = new Core(main_task_runner, io_task_runner, binary_path, | 492 core_ = new Core(main_task_runner, io_task_runner, binary_path, |
493 launch_elevated, channel_security); | 493 launch_elevated, channel_security); |
494 if (!core_->Initialize(session_id)) { | 494 if (!core_->Initialize(session_id)) { |
495 core_->Stop(); | 495 core_->Stop(); |
496 core_ = NULL; | 496 core_ = NULL; |
497 } | 497 } |
498 } | 498 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 bool WtsSessionProcessDelegate::LaunchProcess( | 530 bool WtsSessionProcessDelegate::LaunchProcess( |
531 IPC::Listener* delegate, | 531 IPC::Listener* delegate, |
532 base::win::ScopedHandle* process_exit_event_out) { | 532 base::win::ScopedHandle* process_exit_event_out) { |
533 if (!core_) | 533 if (!core_) |
534 return false; | 534 return false; |
535 | 535 |
536 return core_->LaunchProcess(delegate, process_exit_event_out); | 536 return core_->LaunchProcess(delegate, process_exit_event_out); |
537 } | 537 } |
538 | 538 |
539 } // namespace remoting | 539 } // namespace remoting |
OLD | NEW |