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