Chromium Code Reviews| Index: remoting/host/daemon_process_win.cc |
| diff --git a/remoting/host/daemon_process_win.cc b/remoting/host/daemon_process_win.cc |
| index 5b0a57d4f79cfcdd3aa8ac5e3c9149866fdfd3e6..59756b83dcd8e14627fe8c8e79f0cca5f099649d 100644 |
| --- a/remoting/host/daemon_process_win.cc |
| +++ b/remoting/host/daemon_process_win.cc |
| @@ -41,9 +41,15 @@ class DaemonProcessWin : public DaemonProcess { |
| const base::Closure& stopped_callback); |
| virtual ~DaemonProcessWin(); |
| - // Sends an IPC message to the worker process. This method can be called only |
| - // after successful Start() and until Stop() is called or an error occurred. |
| + // WorkerProcessIpcDelegate implementation. |
| + virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| + |
| + // DaemonProcess overrides. |
| virtual void SendToNetwork(IPC::Message* message) OVERRIDE; |
| + virtual bool OnDesktopSessionAgentAttached( |
| + int terminal_id, |
| + base::ProcessHandle desktop_process, |
| + IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; |
| protected: |
| // Stoppable implementation. |
| @@ -57,6 +63,9 @@ class DaemonProcessWin : public DaemonProcess { |
| private: |
| scoped_ptr<WorkerProcessLauncher> network_launcher_; |
| + // Handle of the network process. |
| + ScopedHandle network_process_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin); |
| }; |
| @@ -74,6 +83,17 @@ DaemonProcessWin::~DaemonProcessWin() { |
| CHECK_EQ(stoppable_state(), Stoppable::kStopped); |
| } |
| +void DaemonProcessWin::OnChannelConnected(int32 peer_pid) { |
| + // Obtain the handle of the network process. |
| + network_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); |
| + if (!network_process_.IsValid()) { |
| + RestartNetworkProcess(FROM_HERE); |
| + return; |
| + } |
| + |
| + DaemonProcess::OnChannelConnected(peer_pid); |
| +} |
| + |
| void DaemonProcessWin::SendToNetwork(IPC::Message* message) { |
| if (network_launcher_) { |
| network_launcher_->Send(message); |
| @@ -82,6 +102,31 @@ void DaemonProcessWin::SendToNetwork(IPC::Message* message) { |
| } |
| } |
| +bool DaemonProcessWin::OnDesktopSessionAgentAttached( |
|
Sergey Ulanov
2012/10/24 20:12:01
Did you mean to implement this method in DaemonPro
alexeypa (please no reviews)
2012/10/24 21:41:51
Done.
|
| + int terminal_id, |
| + base::ProcessHandle desktop_process, |
| + IPC::PlatformFileForTransit desktop_pipe) { |
| + // Prepare |desktop_process| handle for sending over to the network process. |
| + IPC::PlatformFileForTransit desktop_process_for_transit = |
| + IPC::GetFileHandleForProcess(desktop_process, network_process_, false); |
| + if (desktop_process_for_transit == IPC::InvalidPlatformFileForTransit()) { |
| + LOG(ERROR) << "Failed to duplicate the desktop process handle"; |
| + return false; |
| + } |
| + |
| + // Posix: |desktop_pipe| is an auto-close base::FileDescriptor. The IPC |
| + // subsystem will make sure that it is properly closed. |
| + // Windows: |desktop_pipe| is a handle in the desktop process. It will be |
| + // duplicated directly from the desktop process by the network process. |
| +#if defined(OS_POSIX) |
| + DCHECK(desktop_pipe.auto_close); |
| +#endif // defined(OS_POSIX) |
| + |
| + SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( |
| + terminal_id, desktop_process_for_transit, desktop_pipe)); |
| + return true; |
| +} |
| + |
| void DaemonProcessWin::DoStop() { |
| DCHECK(caller_task_runner()->BelongsToCurrentThread()); |