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

Side by Side Diff: cloud_print/service/win/service_controller.cc

Issue 12989026: Stops service between status check (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "cloud_print/service/win/service_controller.h" 5 #include "cloud_print/service/win/service_controller.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <atlctl.h> 9 #include <atlctl.h>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 HRESULT hr = OpenService(name_, SERVICE_STOP | SERVICE_QUERY_STATUS, 99 HRESULT hr = OpenService(name_, SERVICE_STOP | SERVICE_QUERY_STATUS,
100 &service); 100 &service);
101 if (FAILED(hr)) 101 if (FAILED(hr))
102 return hr; 102 return hr;
103 SERVICE_STATUS status = {0}; 103 SERVICE_STATUS status = {0};
104 if (!::ControlService(service, SERVICE_CONTROL_STOP, &status)) 104 if (!::ControlService(service, SERVICE_CONTROL_STOP, &status))
105 return HResultFromLastError(); 105 return HResultFromLastError();
106 while (::QueryServiceStatus(service, &status) && 106 while (::QueryServiceStatus(service, &status) &&
107 status.dwCurrentState > SERVICE_STOPPED) { 107 status.dwCurrentState > SERVICE_STOPPED) {
108 Sleep(500); 108 Sleep(500);
109 ::ControlService(service, SERVICE_CONTROL_STOP, &status);
109 } 110 }
110 return S_OK; 111 return S_OK;
111 } 112 }
112 113
113 HRESULT ServiceController::InstallService(const string16& user, 114 HRESULT ServiceController::InstallService(const string16& user,
114 const string16& password, 115 const string16& password,
115 const std::string& run_switch, 116 const std::string& run_switch,
116 const base::FilePath& user_data_dir) { 117 const base::FilePath& user_data_dir) {
117 // TODO(vitalybuka): consider "lite" version if we don't want unregister 118 // TODO(vitalybuka): consider "lite" version if we don't want unregister
118 // printers here. 119 // printers here.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (service) { 174 if (service) {
174 if (!::DeleteService(service)) { 175 if (!::DeleteService(service)) {
175 LOG(ERROR) << "Failed to uninstall service"; 176 LOG(ERROR) << "Failed to uninstall service";
176 hr = HResultFromLastError(); 177 hr = HResultFromLastError();
177 } 178 }
178 } 179 }
179 UpdateRegistryAppId(false); 180 UpdateRegistryAppId(false);
180 return hr; 181 return hr;
181 } 182 }
182 183
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698