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

Side by Side Diff: remoting/host/setup/daemon_controller_delegate_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, 3 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/remoting_me2me_host.cc ('k') | remoting/host/win/chromoting_module.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 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(NULL, 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( 101 ScopedScHandle service(::OpenServiceW(scmanager.Get(), kWindowsServiceName,
102 ::OpenServiceW(scmanager, kWindowsServiceName, SERVICE_QUERY_STATUS)); 102 SERVICE_QUERY_STATUS));
103 if (!service.IsValid()) { 103 if (!service.IsValid()) {
104 DWORD error = GetLastError(); 104 DWORD error = GetLastError();
105 if (error != ERROR_SERVICE_DOES_NOT_EXIST) { 105 if (error != ERROR_SERVICE_DOES_NOT_EXIST) {
106 PLOG(ERROR) << "Failed to open to the '" << kWindowsServiceName 106 PLOG(ERROR) << "Failed to open to the '" << kWindowsServiceName
107 << "' service"; 107 << "' service";
108 } 108 }
109 return error; 109 return error;
110 } 110 }
111 111
112 service_out->Set(service.Take()); 112 service_out->Set(service.Take());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
149 // notifications rather than polling. 149 // notifications rather than polling.
150 ScopedScHandle service; 150 ScopedScHandle service;
151 DWORD error = OpenService(&service); 151 DWORD error = OpenService(&service);
152 152
153 switch (error) { 153 switch (error) {
154 case ERROR_SUCCESS: { 154 case ERROR_SUCCESS: {
155 SERVICE_STATUS status; 155 SERVICE_STATUS status;
156 if (::QueryServiceStatus(service, &status)) { 156 if (::QueryServiceStatus(service.Get(), &status)) {
157 return ConvertToDaemonState(status.dwCurrentState); 157 return ConvertToDaemonState(status.dwCurrentState);
158 } else { 158 } else {
159 PLOG(ERROR) << "Failed to query the state of the '" 159 PLOG(ERROR) << "Failed to query the state of the '"
160 << kWindowsServiceName << "' service"; 160 << kWindowsServiceName << "' service";
161 return DaemonController::STATE_UNKNOWN; 161 return DaemonController::STATE_UNKNOWN;
162 } 162 }
163 break; 163 break;
164 } 164 }
165 case ERROR_SERVICE_DOES_NOT_EXIST: 165 case ERROR_SERVICE_DOES_NOT_EXIST:
166 return DaemonController::STATE_NOT_INSTALLED; 166 return DaemonController::STATE_NOT_INSTALLED;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 InvokeCompletionCallback(done, hr); 458 InvokeCompletionCallback(done, hr);
459 } 459 }
460 460
461 scoped_refptr<DaemonController> DaemonController::Create() { 461 scoped_refptr<DaemonController> DaemonController::Create() {
462 scoped_ptr<DaemonController::Delegate> delegate( 462 scoped_ptr<DaemonController::Delegate> delegate(
463 new DaemonControllerDelegateWin()); 463 new DaemonControllerDelegateWin());
464 return new DaemonController(delegate.Pass()); 464 return new DaemonController(delegate.Pass());
465 } 465 }
466 466
467 } // namespace remoting 467 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/host/win/chromoting_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698