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

Side by Side Diff: remoting/host/setup/daemon_controller_delegate_win.cc

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/setup/daemon_controller_delegate_win.h" 5 #include "remoting/host/setup/daemon_controller_delegate_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.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/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 default: 84 default:
85 NOTREACHED(); 85 NOTREACHED();
86 return DaemonController::STATE_UNKNOWN; 86 return DaemonController::STATE_UNKNOWN;
87 } 87 }
88 } 88 }
89 89
90 DWORD OpenService(ScopedScHandle* service_out) { 90 DWORD OpenService(ScopedScHandle* service_out) {
91 // Open the service and query its current state. 91 // Open the service and query its current state.
92 ScopedScHandle scmanager( 92 ScopedScHandle scmanager(
93 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE, 93 ::OpenSCManagerW(nullptr, SERVICES_ACTIVE_DATABASE,
94 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); 94 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
95 if (!scmanager.IsValid()) { 95 if (!scmanager.IsValid()) {
96 DWORD error = GetLastError(); 96 DWORD error = GetLastError();
97 PLOG(ERROR) << "Failed to connect to the service control manager"; 97 PLOG(ERROR) << "Failed to connect to the service control manager";
98 return error; 98 return error;
99 } 99 }
100 100
101 ScopedScHandle service(::OpenServiceW(scmanager.Get(), kWindowsServiceName, 101 ScopedScHandle service(::OpenServiceW(scmanager.Get(), kWindowsServiceName,
102 SERVICE_QUERY_STATUS)); 102 SERVICE_QUERY_STATUS));
103 if (!service.IsValid()) { 103 if (!service.IsValid()) {
(...skipping 24 matching lines...) Expand all
128 128
129 void InvokeCompletionCallback( 129 void InvokeCompletionCallback(
130 const DaemonController::CompletionCallback& done, HRESULT hr) { 130 const DaemonController::CompletionCallback& done, HRESULT hr) {
131 done.Run(HResultToAsyncResult(hr)); 131 done.Run(HResultToAsyncResult(hr));
132 } 132 }
133 133
134 } // namespace 134 } // namespace
135 135
136 DaemonControllerDelegateWin::DaemonControllerDelegateWin() 136 DaemonControllerDelegateWin::DaemonControllerDelegateWin()
137 : control_is_elevated_(false), 137 : control_is_elevated_(false),
138 window_handle_(NULL) { 138 window_handle_(nullptr) {
139 } 139 }
140 140
141 DaemonControllerDelegateWin::~DaemonControllerDelegateWin() { 141 DaemonControllerDelegateWin::~DaemonControllerDelegateWin() {
142 } 142 }
143 143
144 DaemonController::State DaemonControllerDelegateWin::GetState() { 144 DaemonController::State DaemonControllerDelegateWin::GetState() {
145 if (base::win::GetVersion() < base::win::VERSION_XP) { 145 if (base::win::GetVersion() < base::win::VERSION_XP) {
146 return DaemonController::STATE_NOT_IMPLEMENTED; 146 return DaemonController::STATE_NOT_IMPLEMENTED;
147 } 147 }
148 // TODO(alexeypa): Make the thread alertable, so we can switch to APC 148 // TODO(alexeypa): Make the thread alertable, so we can switch to APC
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 void DaemonControllerDelegateWin::UpdateConfig( 235 void DaemonControllerDelegateWin::UpdateConfig(
236 scoped_ptr<base::DictionaryValue> config, 236 scoped_ptr<base::DictionaryValue> config,
237 const DaemonController::CompletionCallback& done) { 237 const DaemonController::CompletionCallback& done) {
238 HRESULT hr = ActivateElevatedController(); 238 HRESULT hr = ActivateElevatedController();
239 if (FAILED(hr)) { 239 if (FAILED(hr)) {
240 InvokeCompletionCallback(done, hr); 240 InvokeCompletionCallback(done, hr);
241 return; 241 return;
242 } 242 }
243 243
244 // Update the configuration. 244 // Update the configuration.
245 ScopedBstr config_str(NULL); 245 ScopedBstr config_str(nullptr);
246 ConfigToString(*config, &config_str); 246 ConfigToString(*config, &config_str);
247 if (config_str == NULL) { 247 if (config_str == nullptr) {
248 InvokeCompletionCallback(done, E_OUTOFMEMORY); 248 InvokeCompletionCallback(done, E_OUTOFMEMORY);
249 return; 249 return;
250 } 250 }
251 251
252 // Make sure that the PIN confirmation dialog is focused properly. 252 // Make sure that the PIN confirmation dialog is focused properly.
253 hr = control_->SetOwnerWindow( 253 hr = control_->SetOwnerWindow(
254 reinterpret_cast<LONG_PTR>(GetTopLevelWindow(window_handle_))); 254 reinterpret_cast<LONG_PTR>(GetTopLevelWindow(window_handle_)));
255 if (FAILED(hr)) { 255 if (FAILED(hr)) {
256 InvokeCompletionCallback(done, hr); 256 InvokeCompletionCallback(done, hr);
257 return; 257 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 consent.set_by_policy = false; 298 consent.set_by_policy = false;
299 299
300 // Activate the Daemon Controller and see if it supports |IDaemonControl2|. 300 // Activate the Daemon Controller and see if it supports |IDaemonControl2|.
301 HRESULT hr = ActivateController(); 301 HRESULT hr = ActivateController();
302 if (FAILED(hr)) { 302 if (FAILED(hr)) {
303 // The host is not installed yet. Assume that the user didn't consent to 303 // The host is not installed yet. Assume that the user didn't consent to
304 // collecting crash dumps. 304 // collecting crash dumps.
305 return consent; 305 return consent;
306 } 306 }
307 307
308 if (control2_.get() == NULL) { 308 if (control2_.get() == nullptr) {
309 // The host is installed and does not support crash dump reporting. 309 // The host is installed and does not support crash dump reporting.
310 return consent; 310 return consent;
311 } 311 }
312 312
313 // Get the recorded user's consent. 313 // Get the recorded user's consent.
314 BOOL allowed; 314 BOOL allowed;
315 BOOL set_by_policy; 315 BOOL set_by_policy;
316 hr = control2_->GetUsageStatsConsent(&allowed, &set_by_policy); 316 hr = control2_->GetUsageStatsConsent(&allowed, &set_by_policy);
317 if (FAILED(hr)) { 317 if (FAILED(hr)) {
318 // If the user's consent is not recorded yet, assume that the user didn't 318 // If the user's consent is not recorded yet, assume that the user didn't
319 // consent to collecting crash dumps. 319 // consent to collecting crash dumps.
320 return consent; 320 return consent;
321 } 321 }
322 322
323 consent.allowed = !!allowed; 323 consent.allowed = !!allowed;
324 consent.set_by_policy = !!set_by_policy; 324 consent.set_by_policy = !!set_by_policy;
325 return consent; 325 return consent;
326 } 326 }
327 327
328 HRESULT DaemonControllerDelegateWin::ActivateController() { 328 HRESULT DaemonControllerDelegateWin::ActivateController() {
329 if (!control_.get()) { 329 if (!control_.get()) {
330 CLSID class_id; 330 CLSID class_id;
331 HRESULT hr = CLSIDFromProgID(kDaemonController, &class_id); 331 HRESULT hr = CLSIDFromProgID(kDaemonController, &class_id);
332 if (FAILED(hr)) { 332 if (FAILED(hr)) {
333 return hr; 333 return hr;
334 } 334 }
335 335
336 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER, 336 hr = CoCreateInstance(class_id, nullptr, CLSCTX_LOCAL_SERVER,
337 IID_IDaemonControl, control_.ReceiveVoid()); 337 IID_IDaemonControl, control_.ReceiveVoid());
338 if (FAILED(hr)) { 338 if (FAILED(hr)) {
339 return hr; 339 return hr;
340 } 340 }
341 341
342 // Ignore the error. IID_IDaemonControl2 is optional. 342 // Ignore the error. IID_IDaemonControl2 is optional.
343 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid()); 343 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid());
344 344
345 // Release |control_| upon expiration of the timeout. 345 // Release |control_| upon expiration of the timeout.
346 release_timer_.reset(new base::OneShotTimer<DaemonControllerDelegateWin>()); 346 release_timer_.reset(new base::OneShotTimer<DaemonControllerDelegateWin>());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Record the user's consent. 425 // Record the user's consent.
426 if (control2_.get()) { 426 if (control2_.get()) {
427 hr = control2_->SetUsageStatsConsent(consent); 427 hr = control2_->SetUsageStatsConsent(consent);
428 if (FAILED(hr)) { 428 if (FAILED(hr)) {
429 InvokeCompletionCallback(done, hr); 429 InvokeCompletionCallback(done, hr);
430 return; 430 return;
431 } 431 }
432 } 432 }
433 433
434 // Set the configuration. 434 // Set the configuration.
435 ScopedBstr config_str(NULL); 435 ScopedBstr config_str(nullptr);
436 ConfigToString(*config, &config_str); 436 ConfigToString(*config, &config_str);
437 if (config_str == NULL) { 437 if (config_str == nullptr) {
438 InvokeCompletionCallback(done, E_OUTOFMEMORY); 438 InvokeCompletionCallback(done, E_OUTOFMEMORY);
439 return; 439 return;
440 } 440 }
441 441
442 hr = control_->SetOwnerWindow( 442 hr = control_->SetOwnerWindow(
443 reinterpret_cast<LONG_PTR>(GetTopLevelWindow(window_handle_))); 443 reinterpret_cast<LONG_PTR>(GetTopLevelWindow(window_handle_)));
444 if (FAILED(hr)) { 444 if (FAILED(hr)) {
445 InvokeCompletionCallback(done, hr); 445 InvokeCompletionCallback(done, hr);
446 return; 446 return;
447 } 447 }
448 448
449 hr = control_->SetConfig(config_str); 449 hr = control_->SetConfig(config_str);
450 if (FAILED(hr)) { 450 if (FAILED(hr)) {
451 InvokeCompletionCallback(done, hr); 451 InvokeCompletionCallback(done, hr);
452 return; 452 return;
453 } 453 }
454 454
455 // Start daemon. 455 // Start daemon.
456 hr = control_->StartDaemon(); 456 hr = control_->StartDaemon();
457 InvokeCompletionCallback(done, hr); 457 InvokeCompletionCallback(done, hr);
458 } 458 }
459 459
460 scoped_refptr<DaemonController> DaemonController::Create() { 460 scoped_refptr<DaemonController> DaemonController::Create() {
461 scoped_ptr<DaemonController::Delegate> delegate( 461 scoped_ptr<DaemonController::Delegate> delegate(
462 new DaemonControllerDelegateWin()); 462 new DaemonControllerDelegateWin());
463 return new DaemonController(delegate.Pass()); 463 return new DaemonController(delegate.Pass());
464 } 464 }
465 465
466 } // namespace remoting 466 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/daemon_controller_delegate_mac.mm ('k') | remoting/host/setup/daemon_installer_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698