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

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

Issue 602763003: Remove implicit HANDLE conversions from remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | remoting/host/desktop_session_proxy.cc » ('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 "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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 bool DaemonProcessWin::OnDesktopSessionAgentAttached( 159 bool DaemonProcessWin::OnDesktopSessionAgentAttached(
160 int terminal_id, 160 int terminal_id,
161 base::ProcessHandle desktop_process, 161 base::ProcessHandle desktop_process,
162 IPC::PlatformFileForTransit desktop_pipe) { 162 IPC::PlatformFileForTransit desktop_pipe) {
163 // Prepare |desktop_process| handle for sending over to the network process. 163 // Prepare |desktop_process| handle for sending over to the network process.
164 base::ProcessHandle desktop_process_for_transit; 164 base::ProcessHandle desktop_process_for_transit;
165 if (!DuplicateHandle(GetCurrentProcess(), 165 if (!DuplicateHandle(GetCurrentProcess(),
166 desktop_process, 166 desktop_process,
167 network_process_, 167 network_process_.Get(),
168 &desktop_process_for_transit, 168 &desktop_process_for_transit,
169 0, 169 0,
170 FALSE, 170 FALSE,
171 DUPLICATE_SAME_ACCESS)) { 171 DUPLICATE_SAME_ACCESS)) {
172 PLOG(ERROR) << "Failed to duplicate the desktop process handle"; 172 PLOG(ERROR) << "Failed to duplicate the desktop process handle";
173 return false; 173 return false;
174 } 174 }
175 175
176 // |desktop_pipe| is a handle in the desktop process. It will be duplicated 176 // |desktop_pipe| is a handle in the desktop process. It will be duplicated
177 // by the network process directly from the desktop process. 177 // by the network process directly from the desktop process.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 ScopedScHandle scmanager( 240 ScopedScHandle scmanager(
241 OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, 241 OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE,
242 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); 242 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
243 if (!scmanager.IsValid()) { 243 if (!scmanager.IsValid()) {
244 PLOG(INFO) << "Failed to connect to the service control manager"; 244 PLOG(INFO) << "Failed to connect to the service control manager";
245 return; 245 return;
246 } 246 }
247 247
248 DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS; 248 DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS;
249 ScopedScHandle service( 249 ScopedScHandle service(
250 OpenService(scmanager, kWindowsServiceName, desired_access)); 250 OpenService(scmanager.Get(), kWindowsServiceName, desired_access));
251 if (!service.IsValid()) { 251 if (!service.IsValid()) {
252 PLOG(INFO) << "Failed to open to the '" << kWindowsServiceName 252 PLOG(INFO) << "Failed to open to the '" << kWindowsServiceName
253 << "' service"; 253 << "' service";
254 return; 254 return;
255 } 255 }
256 256
257 // Change the service start type to 'manual'. All |NULL| parameters below mean 257 // Change the service start type to 'manual'. All |NULL| parameters below mean
258 // that there is no change to the corresponding service parameter. 258 // that there is no change to the corresponding service parameter.
259 if (!ChangeServiceConfig(service, 259 if (!ChangeServiceConfig(service.Get(),
260 SERVICE_NO_CHANGE, 260 SERVICE_NO_CHANGE,
261 SERVICE_DEMAND_START, 261 SERVICE_DEMAND_START,
262 SERVICE_NO_CHANGE, 262 SERVICE_NO_CHANGE,
263 NULL, 263 NULL,
264 NULL, 264 NULL,
265 NULL, 265 NULL,
266 NULL, 266 NULL,
267 NULL, 267 NULL,
268 NULL, 268 NULL,
269 NULL)) { 269 NULL)) {
270 PLOG(INFO) << "Failed to change the '" << kWindowsServiceName 270 PLOG(INFO) << "Failed to change the '" << kWindowsServiceName
271 << "'service start type to 'manual'"; 271 << "'service start type to 'manual'";
272 } 272 }
273 } 273 }
274 274
275 bool DaemonProcessWin::InitializePairingRegistry() { 275 bool DaemonProcessWin::InitializePairingRegistry() {
276 if (!pairing_registry_privileged_key_.Valid()) { 276 if (!pairing_registry_privileged_key_.Valid()) {
277 if (!OpenPairingRegistry()) 277 if (!OpenPairingRegistry())
278 return false; 278 return false;
279 } 279 }
280 280
281 // Duplicate handles to the network process. 281 // Duplicate handles to the network process.
282 IPC::PlatformFileForTransit privileged_key = GetRegistryKeyForTransit( 282 IPC::PlatformFileForTransit privileged_key = GetRegistryKeyForTransit(
283 network_process_, pairing_registry_privileged_key_); 283 network_process_.Get(), pairing_registry_privileged_key_);
284 IPC::PlatformFileForTransit unprivileged_key = GetRegistryKeyForTransit( 284 IPC::PlatformFileForTransit unprivileged_key = GetRegistryKeyForTransit(
285 network_process_, pairing_registry_unprivileged_key_); 285 network_process_.Get(), pairing_registry_unprivileged_key_);
286 if (!(privileged_key && unprivileged_key)) 286 if (!(privileged_key && unprivileged_key))
287 return false; 287 return false;
288 288
289 // Initialize the pairing registry in the network process. This has to be done 289 // Initialize the pairing registry in the network process. This has to be done
290 // before the host configuration is sent, otherwise the host will not use 290 // before the host configuration is sent, otherwise the host will not use
291 // the passed handles. 291 // the passed handles.
292 SendToNetwork(new ChromotingDaemonNetworkMsg_InitializePairingRegistry( 292 SendToNetwork(new ChromotingDaemonNetworkMsg_InitializePairingRegistry(
293 privileged_key, unprivileged_key)); 293 privileged_key, unprivileged_key));
294 return true; 294 return true;
295 } 295 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 << "\\" << kPairingRegistrySecretsKeyName; 327 << "\\" << kPairingRegistrySecretsKeyName;
328 return false; 328 return false;
329 } 329 }
330 330
331 pairing_registry_privileged_key_.Set(privileged.Take()); 331 pairing_registry_privileged_key_.Set(privileged.Take());
332 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); 332 pairing_registry_unprivileged_key_.Set(unprivileged.Take());
333 return true; 333 return true;
334 } 334 }
335 335
336 } // namespace remoting 336 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/desktop_session_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698