OLD | NEW |
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 "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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (!service->IsValid()) | 76 if (!service->IsValid()) |
77 return cloud_print::GetLastHResult(); | 77 return cloud_print::GetLastHResult(); |
78 | 78 |
79 return S_OK; | 79 return S_OK; |
80 } | 80 } |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 ServiceController::ServiceController() | 84 ServiceController::ServiceController() |
85 : name_(cloud_print::LoadLocalString(IDS_SERVICE_NAME)), | 85 : name_(cloud_print::LoadLocalString(IDS_SERVICE_NAME)), |
86 command_line_(CommandLine::NO_PROGRAM) { | 86 command_line_(base::CommandLine::NO_PROGRAM) { |
87 } | 87 } |
88 | 88 |
89 ServiceController::~ServiceController() { | 89 ServiceController::~ServiceController() { |
90 } | 90 } |
91 | 91 |
92 HRESULT ServiceController::StartService() { | 92 HRESULT ServiceController::StartService() { |
93 ServiceHandle service; | 93 ServiceHandle service; |
94 HRESULT hr = OpenService(name_, SERVICE_START| SERVICE_QUERY_STATUS, | 94 HRESULT hr = OpenService(name_, SERVICE_START| SERVICE_QUERY_STATUS, |
95 &service); | 95 &service); |
96 if (FAILED(hr)) | 96 if (FAILED(hr)) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (FAILED(hr)) | 157 if (FAILED(hr)) |
158 return hr; | 158 return hr; |
159 | 159 |
160 hr = UpdateRegistryAppId(true); | 160 hr = UpdateRegistryAppId(true); |
161 if (FAILED(hr)) | 161 if (FAILED(hr)) |
162 return hr; | 162 return hr; |
163 | 163 |
164 base::FilePath service_path = GetBinary(); | 164 base::FilePath service_path = GetBinary(); |
165 if (!base::PathExists(service_path)) | 165 if (!base::PathExists(service_path)) |
166 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); | 166 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); |
167 CommandLine command_line(service_path); | 167 base::CommandLine command_line(service_path); |
168 command_line.AppendSwitch(run_switch); | 168 command_line.AppendSwitch(run_switch); |
169 if (!user_data_dir.empty()) | 169 if (!user_data_dir.empty()) |
170 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 170 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
171 if (enable_logging) { | 171 if (enable_logging) { |
172 command_line.AppendSwitch(switches::kEnableLogging); | 172 command_line.AppendSwitch(switches::kEnableLogging); |
173 command_line.AppendSwitchASCII(switches::kV, "1"); | 173 command_line.AppendSwitchASCII(switches::kV, "1"); |
174 } | 174 } |
175 | 175 |
176 CopyChromeSwitchesFromCurrentProcess(&command_line); | 176 CopyChromeSwitchesFromCurrentProcess(&command_line); |
177 | 177 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 std::vector<uint8> buffer(config_size, 0); | 298 std::vector<uint8> buffer(config_size, 0); |
299 QUERY_SERVICE_CONFIG* config = | 299 QUERY_SERVICE_CONFIG* config = |
300 reinterpret_cast<QUERY_SERVICE_CONFIG*>(&buffer[0]); | 300 reinterpret_cast<QUERY_SERVICE_CONFIG*>(&buffer[0]); |
301 if (!::QueryServiceConfig(service.Get(), config, buffer.size(), | 301 if (!::QueryServiceConfig(service.Get(), config, buffer.size(), |
302 &config_size) || | 302 &config_size) || |
303 config_size != buffer.size()) { | 303 config_size != buffer.size()) { |
304 return; | 304 return; |
305 } | 305 } |
306 | 306 |
307 command_line_ = CommandLine::FromString(config->lpBinaryPathName); | 307 command_line_ = base::CommandLine::FromString(config->lpBinaryPathName); |
308 if (!command_line_.HasSwitch(kServiceSwitch)) { | 308 if (!command_line_.HasSwitch(kServiceSwitch)) { |
309 state_ = STATE_NOT_FOUND; | 309 state_ = STATE_NOT_FOUND; |
310 return; | 310 return; |
311 } | 311 } |
312 is_logging_enabled_ = command_line_.HasSwitch(switches::kEnableLogging); | 312 is_logging_enabled_ = command_line_.HasSwitch(switches::kEnableLogging); |
313 user_ = config->lpServiceStartName; | 313 user_ = config->lpServiceStartName; |
314 } | 314 } |
315 | 315 |
316 bool ServiceController::is_logging_enabled() const { | 316 bool ServiceController::is_logging_enabled() const { |
317 return command_line_.HasSwitch(switches::kEnableLogging); | 317 return command_line_.HasSwitch(switches::kEnableLogging); |
318 } | 318 } |
OLD | NEW |