| 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 #include "remoting/host/daemon_process.h" | 5 #include "remoting/host/daemon_process.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 53 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 54 | 54 |
| 55 // DaemonProcess overrides. | 55 // DaemonProcess overrides. |
| 56 virtual void SendToNetwork(IPC::Message* message) OVERRIDE; | 56 virtual void SendToNetwork(IPC::Message* message) OVERRIDE; |
| 57 virtual bool OnDesktopSessionAgentAttached( | 57 virtual bool OnDesktopSessionAgentAttached( |
| 58 int terminal_id, | 58 int terminal_id, |
| 59 base::ProcessHandle desktop_process, | 59 base::ProcessHandle desktop_process, |
| 60 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | 60 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 // Stoppable implementation. | |
| 64 virtual void DoStop() OVERRIDE; | |
| 65 | |
| 66 // DaemonProcess implementation. | 63 // DaemonProcess implementation. |
| 67 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( | 64 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( |
| 68 int terminal_id, | 65 int terminal_id, |
| 69 const ScreenResolution& resolution, | 66 const ScreenResolution& resolution, |
| 70 bool virtual_terminal) OVERRIDE; | 67 bool virtual_terminal) OVERRIDE; |
| 71 virtual void DoCrashNetworkProcess( | 68 virtual void DoCrashNetworkProcess( |
| 72 const tracked_objects::Location& location) OVERRIDE; | 69 const tracked_objects::Location& location) OVERRIDE; |
| 73 virtual void LaunchNetworkProcess() OVERRIDE; | 70 virtual void LaunchNetworkProcess() OVERRIDE; |
| 74 | 71 |
| 75 private: | 72 private: |
| 76 scoped_ptr<WorkerProcessLauncher> network_launcher_; | 73 scoped_ptr<WorkerProcessLauncher> network_launcher_; |
| 77 | 74 |
| 78 // Handle of the network process. | 75 // Handle of the network process. |
| 79 ScopedHandle network_process_; | 76 ScopedHandle network_process_; |
| 80 | 77 |
| 81 DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin); | 78 DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin); |
| 82 }; | 79 }; |
| 83 | 80 |
| 84 DaemonProcessWin::DaemonProcessWin( | 81 DaemonProcessWin::DaemonProcessWin( |
| 85 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 82 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 86 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 83 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 87 const base::Closure& stopped_callback) | 84 const base::Closure& stopped_callback) |
| 88 : DaemonProcess(caller_task_runner, io_task_runner, stopped_callback) { | 85 : DaemonProcess(caller_task_runner, io_task_runner, stopped_callback) { |
| 89 } | 86 } |
| 90 | 87 |
| 91 DaemonProcessWin::~DaemonProcessWin() { | 88 DaemonProcessWin::~DaemonProcessWin() { |
| 92 // Make sure that the object is completely stopped. The same check exists | |
| 93 // in Stoppable::~Stoppable() but this one helps us to fail early and | |
| 94 // predictably. | |
| 95 CHECK_EQ(stoppable_state(), Stoppable::kStopped); | |
| 96 } | 89 } |
| 97 | 90 |
| 98 void DaemonProcessWin::OnChannelConnected(int32 peer_pid) { | 91 void DaemonProcessWin::OnChannelConnected(int32 peer_pid) { |
| 99 // Obtain the handle of the network process. | 92 // Obtain the handle of the network process. |
| 100 network_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); | 93 network_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); |
| 101 if (!network_process_.IsValid()) { | 94 if (!network_process_.IsValid()) { |
| 102 CrashNetworkProcess(FROM_HERE); | 95 CrashNetworkProcess(FROM_HERE); |
| 103 return; | 96 return; |
| 104 } | 97 } |
| 105 | 98 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 131 return false; | 124 return false; |
| 132 } | 125 } |
| 133 | 126 |
| 134 // |desktop_pipe| is a handle in the desktop process. It will be duplicated | 127 // |desktop_pipe| is a handle in the desktop process. It will be duplicated |
| 135 // by the network process directly from the desktop process. | 128 // by the network process directly from the desktop process. |
| 136 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( | 129 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( |
| 137 terminal_id, desktop_process_for_transit, desktop_pipe)); | 130 terminal_id, desktop_process_for_transit, desktop_pipe)); |
| 138 return true; | 131 return true; |
| 139 } | 132 } |
| 140 | 133 |
| 141 void DaemonProcessWin::DoStop() { | |
| 142 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | |
| 143 | |
| 144 network_launcher_.reset(); | |
| 145 DaemonProcess::DoStop(); | |
| 146 } | |
| 147 | |
| 148 scoped_ptr<DesktopSession> DaemonProcessWin::DoCreateDesktopSession( | 134 scoped_ptr<DesktopSession> DaemonProcessWin::DoCreateDesktopSession( |
| 149 int terminal_id, | 135 int terminal_id, |
| 150 const ScreenResolution& resolution, | 136 const ScreenResolution& resolution, |
| 151 bool virtual_terminal) { | 137 bool virtual_terminal) { |
| 152 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 138 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 153 | 139 |
| 154 if (virtual_terminal) { | 140 if (virtual_terminal) { |
| 155 return DesktopSessionWin::CreateForVirtualTerminal( | 141 return DesktopSessionWin::CreateForVirtualTerminal( |
| 156 caller_task_runner(), io_task_runner(), this, terminal_id, resolution); | 142 caller_task_runner(), io_task_runner(), this, terminal_id, resolution); |
| 157 } else { | 143 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 180 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 195 const base::Closure& stopped_callback) { | 181 const base::Closure& stopped_callback) { |
| 196 scoped_ptr<DaemonProcessWin> daemon_process( | 182 scoped_ptr<DaemonProcessWin> daemon_process( |
| 197 new DaemonProcessWin(caller_task_runner, io_task_runner, | 183 new DaemonProcessWin(caller_task_runner, io_task_runner, |
| 198 stopped_callback)); | 184 stopped_callback)); |
| 199 daemon_process->Initialize(); | 185 daemon_process->Initialize(); |
| 200 return daemon_process.PassAs<DaemonProcess>(); | 186 return daemon_process.PassAs<DaemonProcess>(); |
| 201 } | 187 } |
| 202 | 188 |
| 203 } // namespace remoting | 189 } // namespace remoting |
| OLD | NEW |