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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 IPC::PlatformFileForTransit desktop_pipe) { | 160 IPC::PlatformFileForTransit desktop_pipe) { |
161 // Prepare |desktop_process| handle for sending over to the network process. | 161 // Prepare |desktop_process| handle for sending over to the network process. |
162 base::ProcessHandle desktop_process_for_transit; | 162 base::ProcessHandle desktop_process_for_transit; |
163 if (!DuplicateHandle(GetCurrentProcess(), | 163 if (!DuplicateHandle(GetCurrentProcess(), |
164 desktop_process, | 164 desktop_process, |
165 network_process_, | 165 network_process_, |
166 &desktop_process_for_transit, | 166 &desktop_process_for_transit, |
167 0, | 167 0, |
168 FALSE, | 168 FALSE, |
169 DUPLICATE_SAME_ACCESS)) { | 169 DUPLICATE_SAME_ACCESS)) { |
170 LOG_GETLASTERROR(ERROR) << "Failed to duplicate the desktop process handle"; | 170 PLOG(ERROR) << "Failed to duplicate the desktop process handle"; |
171 return false; | 171 return false; |
172 } | 172 } |
173 | 173 |
174 // |desktop_pipe| is a handle in the desktop process. It will be duplicated | 174 // |desktop_pipe| is a handle in the desktop process. It will be duplicated |
175 // by the network process directly from the desktop process. | 175 // by the network process directly from the desktop process. |
176 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( | 176 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( |
177 terminal_id, desktop_process_for_transit, desktop_pipe)); | 177 terminal_id, desktop_process_for_transit, desktop_pipe)); |
178 return true; | 178 return true; |
179 } | 179 } |
180 | 180 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 stopped_callback)); | 231 stopped_callback)); |
232 daemon_process->Initialize(); | 232 daemon_process->Initialize(); |
233 return daemon_process.PassAs<DaemonProcess>(); | 233 return daemon_process.PassAs<DaemonProcess>(); |
234 } | 234 } |
235 | 235 |
236 void DaemonProcessWin::DisableAutoStart() { | 236 void DaemonProcessWin::DisableAutoStart() { |
237 ScopedScHandle scmanager( | 237 ScopedScHandle scmanager( |
238 OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, | 238 OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, |
239 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); | 239 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); |
240 if (!scmanager.IsValid()) { | 240 if (!scmanager.IsValid()) { |
241 LOG_GETLASTERROR(INFO) | 241 PLOG(INFO) << "Failed to connect to the service control manager"; |
242 << "Failed to connect to the service control manager"; | |
243 return; | 242 return; |
244 } | 243 } |
245 | 244 |
246 DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS; | 245 DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS; |
247 ScopedScHandle service( | 246 ScopedScHandle service( |
248 OpenService(scmanager, kWindowsServiceName, desired_access)); | 247 OpenService(scmanager, kWindowsServiceName, desired_access)); |
249 if (!service.IsValid()) { | 248 if (!service.IsValid()) { |
250 LOG_GETLASTERROR(INFO) | 249 PLOG(INFO) << "Failed to open to the '" << kWindowsServiceName |
251 << "Failed to open to the '" << kWindowsServiceName << "' service"; | 250 << "' service"; |
252 return; | 251 return; |
253 } | 252 } |
254 | 253 |
255 // Change the service start type to 'manual'. All |NULL| parameters below mean | 254 // Change the service start type to 'manual'. All |NULL| parameters below mean |
256 // that there is no change to the corresponding service parameter. | 255 // that there is no change to the corresponding service parameter. |
257 if (!ChangeServiceConfig(service, | 256 if (!ChangeServiceConfig(service, |
258 SERVICE_NO_CHANGE, | 257 SERVICE_NO_CHANGE, |
259 SERVICE_DEMAND_START, | 258 SERVICE_DEMAND_START, |
260 SERVICE_NO_CHANGE, | 259 SERVICE_NO_CHANGE, |
261 NULL, | 260 NULL, |
262 NULL, | 261 NULL, |
263 NULL, | 262 NULL, |
264 NULL, | 263 NULL, |
265 NULL, | 264 NULL, |
266 NULL, | 265 NULL, |
267 NULL)) { | 266 NULL)) { |
268 LOG_GETLASTERROR(INFO) | 267 PLOG(INFO) << "Failed to change the '" << kWindowsServiceName |
269 << "Failed to change the '" << kWindowsServiceName | 268 << "'service start type to 'manual'"; |
270 << "'service start type to 'manual'"; | |
271 } | 269 } |
272 } | 270 } |
273 | 271 |
274 bool DaemonProcessWin::InitializePairingRegistry() { | 272 bool DaemonProcessWin::InitializePairingRegistry() { |
275 if (!pairing_registry_privileged_key_.Valid()) { | 273 if (!pairing_registry_privileged_key_.Valid()) { |
276 if (!OpenPairingRegistry()) | 274 if (!OpenPairingRegistry()) |
277 return false; | 275 return false; |
278 } | 276 } |
279 | 277 |
280 // Duplicate handles to the network process. | 278 // Duplicate handles to the network process. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 << "\\" << kPairingRegistrySecretsKeyName; | 324 << "\\" << kPairingRegistrySecretsKeyName; |
327 return false; | 325 return false; |
328 } | 326 } |
329 | 327 |
330 pairing_registry_privileged_key_.Set(privileged.Take()); | 328 pairing_registry_privileged_key_.Set(privileged.Take()); |
331 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); | 329 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); |
332 return true; | 330 return true; |
333 } | 331 } |
334 | 332 |
335 } // namespace remoting | 333 } // namespace remoting |
OLD | NEW |