Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: remoting/host/daemon_process_win.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/daemon_process_unittest.cc ('k') | remoting/host/desktop_capturer_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 10 #include <utility>
10 11
11 #include "base/base_switches.h" 12 #include "base/base_switches.h"
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.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 "remoting/base/auto_thread_task_runner.h" 28 #include "remoting/base/auto_thread_task_runner.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // DaemonProcess overrides. 82 // DaemonProcess overrides.
83 void SendToNetwork(IPC::Message* message) override; 83 void SendToNetwork(IPC::Message* message) override;
84 bool OnDesktopSessionAgentAttached( 84 bool OnDesktopSessionAgentAttached(
85 int terminal_id, 85 int terminal_id,
86 base::ProcessHandle desktop_process, 86 base::ProcessHandle desktop_process,
87 IPC::PlatformFileForTransit desktop_pipe) override; 87 IPC::PlatformFileForTransit desktop_pipe) override;
88 88
89 protected: 89 protected:
90 // DaemonProcess implementation. 90 // DaemonProcess implementation.
91 scoped_ptr<DesktopSession> DoCreateDesktopSession( 91 std::unique_ptr<DesktopSession> DoCreateDesktopSession(
92 int terminal_id, 92 int terminal_id,
93 const ScreenResolution& resolution, 93 const ScreenResolution& resolution,
94 bool virtual_terminal) override; 94 bool virtual_terminal) override;
95 void DoCrashNetworkProcess( 95 void DoCrashNetworkProcess(
96 const tracked_objects::Location& location) override; 96 const tracked_objects::Location& location) override;
97 void LaunchNetworkProcess() override; 97 void LaunchNetworkProcess() override;
98 98
99 // Changes the service start type to 'manual'. 99 // Changes the service start type to 'manual'.
100 void DisableAutoStart(); 100 void DisableAutoStart();
101 101
102 // Initializes the pairing registry on the host side by sending 102 // Initializes the pairing registry on the host side by sending
103 // ChromotingDaemonNetworkMsg_InitializePairingRegistry message. 103 // ChromotingDaemonNetworkMsg_InitializePairingRegistry message.
104 bool InitializePairingRegistry(); 104 bool InitializePairingRegistry();
105 105
106 // Opens the pairing registry keys. 106 // Opens the pairing registry keys.
107 bool OpenPairingRegistry(); 107 bool OpenPairingRegistry();
108 108
109 private: 109 private:
110 scoped_ptr<WorkerProcessLauncher> network_launcher_; 110 std::unique_ptr<WorkerProcessLauncher> network_launcher_;
111 111
112 // Handle of the network process. 112 // Handle of the network process.
113 ScopedHandle network_process_; 113 ScopedHandle network_process_;
114 114
115 base::win::RegKey pairing_registry_privileged_key_; 115 base::win::RegKey pairing_registry_privileged_key_;
116 base::win::RegKey pairing_registry_unprivileged_key_; 116 base::win::RegKey pairing_registry_unprivileged_key_;
117 117
118 DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin); 118 DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin);
119 }; 119 };
120 120
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return false; 185 return false;
186 } 186 }
187 187
188 // |desktop_pipe| is a handle in the desktop process. It will be duplicated 188 // |desktop_pipe| is a handle in the desktop process. It will be duplicated
189 // by the network process directly from the desktop process. 189 // by the network process directly from the desktop process.
190 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( 190 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached(
191 terminal_id, desktop_process_for_transit, desktop_pipe)); 191 terminal_id, desktop_process_for_transit, desktop_pipe));
192 return true; 192 return true;
193 } 193 }
194 194
195 scoped_ptr<DesktopSession> DaemonProcessWin::DoCreateDesktopSession( 195 std::unique_ptr<DesktopSession> DaemonProcessWin::DoCreateDesktopSession(
196 int terminal_id, 196 int terminal_id,
197 const ScreenResolution& resolution, 197 const ScreenResolution& resolution,
198 bool virtual_terminal) { 198 bool virtual_terminal) {
199 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 199 DCHECK(caller_task_runner()->BelongsToCurrentThread());
200 200
201 if (virtual_terminal) { 201 if (virtual_terminal) {
202 return DesktopSessionWin::CreateForVirtualTerminal( 202 return DesktopSessionWin::CreateForVirtualTerminal(
203 caller_task_runner(), io_task_runner(), this, terminal_id, resolution); 203 caller_task_runner(), io_task_runner(), this, terminal_id, resolution);
204 } else { 204 } else {
205 return DesktopSessionWin::CreateForConsole( 205 return DesktopSessionWin::CreateForConsole(
(...skipping 12 matching lines...) Expand all
218 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 218 DCHECK(caller_task_runner()->BelongsToCurrentThread());
219 DCHECK(!network_launcher_); 219 DCHECK(!network_launcher_);
220 220
221 // Construct the host binary name. 221 // Construct the host binary name.
222 base::FilePath host_binary; 222 base::FilePath host_binary;
223 if (!GetInstalledBinaryPath(kHostBinaryName, &host_binary)) { 223 if (!GetInstalledBinaryPath(kHostBinaryName, &host_binary)) {
224 Stop(); 224 Stop();
225 return; 225 return;
226 } 226 }
227 227
228 scoped_ptr<base::CommandLine> target(new base::CommandLine(host_binary)); 228 std::unique_ptr<base::CommandLine> target(new base::CommandLine(host_binary));
229 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost); 229 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost);
230 target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), 230 target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
231 kCopiedSwitchNames, arraysize(kCopiedSwitchNames)); 231 kCopiedSwitchNames, arraysize(kCopiedSwitchNames));
232 232
233 scoped_ptr<UnprivilegedProcessDelegate> delegate( 233 std::unique_ptr<UnprivilegedProcessDelegate> delegate(
234 new UnprivilegedProcessDelegate(io_task_runner(), std::move(target))); 234 new UnprivilegedProcessDelegate(io_task_runner(), std::move(target)));
235 network_launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this)); 235 network_launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this));
236 } 236 }
237 237
238 scoped_ptr<DaemonProcess> DaemonProcess::Create( 238 std::unique_ptr<DaemonProcess> DaemonProcess::Create(
239 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 239 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
240 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 240 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
241 const base::Closure& stopped_callback) { 241 const base::Closure& stopped_callback) {
242 scoped_ptr<DaemonProcessWin> daemon_process( 242 std::unique_ptr<DaemonProcessWin> daemon_process(new DaemonProcessWin(
243 new DaemonProcessWin(caller_task_runner, io_task_runner, 243 caller_task_runner, io_task_runner, stopped_callback));
244 stopped_callback));
245 daemon_process->Initialize(); 244 daemon_process->Initialize();
246 return std::move(daemon_process); 245 return std::move(daemon_process);
247 } 246 }
248 247
249 void DaemonProcessWin::DisableAutoStart() { 248 void DaemonProcessWin::DisableAutoStart() {
250 ScopedScHandle scmanager( 249 ScopedScHandle scmanager(
251 OpenSCManager(nullptr, SERVICES_ACTIVE_DATABASE, 250 OpenSCManager(nullptr, SERVICES_ACTIVE_DATABASE,
252 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); 251 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
253 if (!scmanager.IsValid()) { 252 if (!scmanager.IsValid()) {
254 PLOG(INFO) << "Failed to connect to the service control manager"; 253 PLOG(INFO) << "Failed to connect to the service control manager";
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 << "\\" << kPairingRegistrySecretsKeyName; 381 << "\\" << kPairingRegistrySecretsKeyName;
383 return false; 382 return false;
384 } 383 }
385 384
386 pairing_registry_privileged_key_.Set(privileged.Take()); 385 pairing_registry_privileged_key_.Set(privileged.Take());
387 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); 386 pairing_registry_unprivileged_key_.Set(unprivileged.Take());
388 return true; 387 return true;
389 } 388 }
390 389
391 } // namespace remoting 390 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/daemon_process_unittest.cc ('k') | remoting/host/desktop_capturer_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698