| 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_message.h" | 26 #include "ipc/ipc_message.h" |
| 27 #include "ipc/ipc_message_macros.h" | 27 #include "ipc/ipc_message_macros.h" |
| 28 #include "mojo/edk/embedder/scoped_ipc_support.h" | |
| 29 #include "remoting/base/auto_thread_task_runner.h" | 28 #include "remoting/base/auto_thread_task_runner.h" |
| 30 #include "remoting/base/scoped_sc_handle_win.h" | 29 #include "remoting/base/scoped_sc_handle_win.h" |
| 31 #include "remoting/host/branding.h" | 30 #include "remoting/host/branding.h" |
| 32 #include "remoting/host/chromoting_messages.h" | 31 #include "remoting/host/chromoting_messages.h" |
| 33 #include "remoting/host/desktop_session_win.h" | 32 #include "remoting/host/desktop_session_win.h" |
| 34 #include "remoting/host/host_exit_codes.h" | 33 #include "remoting/host/host_exit_codes.h" |
| 35 #include "remoting/host/host_main.h" | 34 #include "remoting/host/host_main.h" |
| 36 #include "remoting/host/ipc_constants.h" | 35 #include "remoting/host/ipc_constants.h" |
| 37 #include "remoting/host/pairing_registry_delegate_win.h" | 36 #include "remoting/host/pairing_registry_delegate_win.h" |
| 38 #include "remoting/host/screen_resolution.h" | 37 #include "remoting/host/screen_resolution.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void DisableAutoStart(); | 98 void DisableAutoStart(); |
| 100 | 99 |
| 101 // Initializes the pairing registry on the host side by sending | 100 // Initializes the pairing registry on the host side by sending |
| 102 // ChromotingDaemonNetworkMsg_InitializePairingRegistry message. | 101 // ChromotingDaemonNetworkMsg_InitializePairingRegistry message. |
| 103 bool InitializePairingRegistry(); | 102 bool InitializePairingRegistry(); |
| 104 | 103 |
| 105 // Opens the pairing registry keys. | 104 // Opens the pairing registry keys. |
| 106 bool OpenPairingRegistry(); | 105 bool OpenPairingRegistry(); |
| 107 | 106 |
| 108 private: | 107 private: |
| 109 // Mojo keeps the task runner passed to it alive forever, so an | |
| 110 // AutoThreadTaskRunner should not be passed to it. Otherwise, the process may | |
| 111 // never shut down cleanly. | |
| 112 mojo::edk::ScopedIPCSupport ipc_support_; | |
| 113 | |
| 114 std::unique_ptr<WorkerProcessLauncher> network_launcher_; | 108 std::unique_ptr<WorkerProcessLauncher> network_launcher_; |
| 115 | 109 |
| 116 // Handle of the network process. | 110 // Handle of the network process. |
| 117 ScopedHandle network_process_; | 111 ScopedHandle network_process_; |
| 118 | 112 |
| 119 base::win::RegKey pairing_registry_privileged_key_; | 113 base::win::RegKey pairing_registry_privileged_key_; |
| 120 base::win::RegKey pairing_registry_unprivileged_key_; | 114 base::win::RegKey pairing_registry_unprivileged_key_; |
| 121 | 115 |
| 122 DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin); | 116 DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin); |
| 123 }; | 117 }; |
| 124 | 118 |
| 125 DaemonProcessWin::DaemonProcessWin( | 119 DaemonProcessWin::DaemonProcessWin( |
| 126 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 120 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 127 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 121 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 128 const base::Closure& stopped_callback) | 122 const base::Closure& stopped_callback) |
| 129 : DaemonProcess(caller_task_runner, io_task_runner, stopped_callback), | 123 : DaemonProcess(caller_task_runner, io_task_runner, stopped_callback) { |
| 130 ipc_support_(io_task_runner->task_runner()) {} | 124 } |
| 131 | 125 |
| 132 DaemonProcessWin::~DaemonProcessWin() { | 126 DaemonProcessWin::~DaemonProcessWin() { |
| 133 } | 127 } |
| 134 | 128 |
| 135 void DaemonProcessWin::OnChannelConnected(int32_t peer_pid) { | 129 void DaemonProcessWin::OnChannelConnected(int32_t peer_pid) { |
| 136 // Obtain the handle of the network process. | 130 // Obtain the handle of the network process. |
| 137 network_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); | 131 network_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); |
| 138 if (!network_process_.IsValid()) { | 132 if (!network_process_.IsValid()) { |
| 139 CrashNetworkProcess(FROM_HERE); | 133 CrashNetworkProcess(FROM_HERE); |
| 140 return; | 134 return; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 << "\\" << kPairingRegistrySecretsKeyName; | 379 << "\\" << kPairingRegistrySecretsKeyName; |
| 386 return false; | 380 return false; |
| 387 } | 381 } |
| 388 | 382 |
| 389 pairing_registry_privileged_key_.Set(privileged.Take()); | 383 pairing_registry_privileged_key_.Set(privileged.Take()); |
| 390 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); | 384 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); |
| 391 return true; | 385 return true; |
| 392 } | 386 } |
| 393 | 387 |
| 394 } // namespace remoting | 388 } // namespace remoting |
| OLD | NEW |