| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
| 24 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
| 25 #include "base/win/win_util.h" | 25 #include "base/win/win_util.h" |
| 26 #include "ipc/ipc_channel_handle.h" |
| 26 #include "ipc/ipc_message.h" | 27 #include "ipc/ipc_message.h" |
| 27 #include "ipc/ipc_message_macros.h" | 28 #include "ipc/ipc_message_macros.h" |
| 28 #include "mojo/edk/embedder/scoped_ipc_support.h" | 29 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 29 #include "remoting/base/auto_thread_task_runner.h" | 30 #include "remoting/base/auto_thread_task_runner.h" |
| 30 #include "remoting/base/scoped_sc_handle_win.h" | 31 #include "remoting/base/scoped_sc_handle_win.h" |
| 31 #include "remoting/host/branding.h" | 32 #include "remoting/host/branding.h" |
| 32 #include "remoting/host/chromoting_messages.h" | 33 #include "remoting/host/chromoting_messages.h" |
| 33 #include "remoting/host/desktop_session_win.h" | 34 #include "remoting/host/desktop_session_win.h" |
| 34 #include "remoting/host/host_exit_codes.h" | 35 #include "remoting/host/host_exit_codes.h" |
| 35 #include "remoting/host/host_main.h" | 36 #include "remoting/host/host_main.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ~DaemonProcessWin() override; | 76 ~DaemonProcessWin() override; |
| 76 | 77 |
| 77 // WorkerProcessIpcDelegate implementation. | 78 // WorkerProcessIpcDelegate implementation. |
| 78 void OnChannelConnected(int32_t peer_pid) override; | 79 void OnChannelConnected(int32_t peer_pid) override; |
| 79 void OnPermanentError(int exit_code) override; | 80 void OnPermanentError(int exit_code) override; |
| 80 | 81 |
| 81 // DaemonProcess overrides. | 82 // DaemonProcess overrides. |
| 82 void SendToNetwork(IPC::Message* message) override; | 83 void SendToNetwork(IPC::Message* message) override; |
| 83 bool OnDesktopSessionAgentAttached( | 84 bool OnDesktopSessionAgentAttached( |
| 84 int terminal_id, | 85 int terminal_id, |
| 85 base::ProcessHandle desktop_process, | 86 const IPC::ChannelHandle& desktop_pipe) override; |
| 86 IPC::PlatformFileForTransit desktop_pipe) override; | |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 // DaemonProcess implementation. | 89 // DaemonProcess implementation. |
| 90 std::unique_ptr<DesktopSession> DoCreateDesktopSession( | 90 std::unique_ptr<DesktopSession> DoCreateDesktopSession( |
| 91 int terminal_id, | 91 int terminal_id, |
| 92 const ScreenResolution& resolution, | 92 const ScreenResolution& resolution, |
| 93 bool virtual_terminal) override; | 93 bool virtual_terminal) override; |
| 94 void DoCrashNetworkProcess( | 94 void DoCrashNetworkProcess( |
| 95 const tracked_objects::Location& location) override; | 95 const tracked_objects::Location& location) override; |
| 96 void LaunchNetworkProcess() override; | 96 void LaunchNetworkProcess() override; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void DaemonProcessWin::SendToNetwork(IPC::Message* message) { | 167 void DaemonProcessWin::SendToNetwork(IPC::Message* message) { |
| 168 if (network_launcher_) { | 168 if (network_launcher_) { |
| 169 network_launcher_->Send(message); | 169 network_launcher_->Send(message); |
| 170 } else { | 170 } else { |
| 171 delete message; | 171 delete message; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool DaemonProcessWin::OnDesktopSessionAgentAttached( | 175 bool DaemonProcessWin::OnDesktopSessionAgentAttached( |
| 176 int terminal_id, | 176 int terminal_id, |
| 177 base::ProcessHandle desktop_process, | 177 const IPC::ChannelHandle& desktop_pipe) { |
| 178 IPC::PlatformFileForTransit desktop_pipe) { | |
| 179 // Prepare |desktop_process| handle for sending over to the network process. | |
| 180 base::ProcessHandle desktop_process_for_transit; | |
| 181 if (!DuplicateHandle(GetCurrentProcess(), | |
| 182 desktop_process, | |
| 183 network_process_.Get(), | |
| 184 &desktop_process_for_transit, | |
| 185 0, | |
| 186 FALSE, | |
| 187 DUPLICATE_SAME_ACCESS)) { | |
| 188 PLOG(ERROR) << "Failed to duplicate the desktop process handle"; | |
| 189 return false; | |
| 190 } | |
| 191 | |
| 192 // |desktop_pipe| is a handle in the desktop process. It will be duplicated | |
| 193 // by the network process directly from the desktop process. | |
| 194 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( | 178 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( |
| 195 terminal_id, desktop_process_for_transit, desktop_pipe)); | 179 terminal_id, desktop_pipe)); |
| 196 return true; | 180 return true; |
| 197 } | 181 } |
| 198 | 182 |
| 199 std::unique_ptr<DesktopSession> DaemonProcessWin::DoCreateDesktopSession( | 183 std::unique_ptr<DesktopSession> DaemonProcessWin::DoCreateDesktopSession( |
| 200 int terminal_id, | 184 int terminal_id, |
| 201 const ScreenResolution& resolution, | 185 const ScreenResolution& resolution, |
| 202 bool virtual_terminal) { | 186 bool virtual_terminal) { |
| 203 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 187 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 204 | 188 |
| 205 if (virtual_terminal) { | 189 if (virtual_terminal) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 << "\\" << kPairingRegistrySecretsKeyName; | 369 << "\\" << kPairingRegistrySecretsKeyName; |
| 386 return false; | 370 return false; |
| 387 } | 371 } |
| 388 | 372 |
| 389 pairing_registry_privileged_key_.Set(privileged.Take()); | 373 pairing_registry_privileged_key_.Set(privileged.Take()); |
| 390 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); | 374 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); |
| 391 return true; | 375 return true; |
| 392 } | 376 } |
| 393 | 377 |
| 394 } // namespace remoting | 378 } // namespace remoting |
| OLD | NEW |