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 "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/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return service.Pass(); | 258 return service.Pass(); |
259 } | 259 } |
260 | 260 |
261 void InvokeCompletionCallback( | 261 void InvokeCompletionCallback( |
262 const DaemonController::CompletionCallback& done, bool success) { | 262 const DaemonController::CompletionCallback& done, bool success) { |
263 DaemonController::AsyncResult async_result = | 263 DaemonController::AsyncResult async_result = |
264 success ? DaemonController::RESULT_OK : DaemonController::RESULT_FAILED; | 264 success ? DaemonController::RESULT_OK : DaemonController::RESULT_FAILED; |
265 done.Run(async_result); | 265 done.Run(async_result); |
266 } | 266 } |
267 | 267 |
268 bool SetConfig(const std::string& config) { | |
269 // Determine the config directory path and create it if necessary. | |
270 base::FilePath config_dir = remoting::GetConfigDir(); | |
271 if (!base::CreateDirectory(config_dir)) { | |
272 PLOG(ERROR) << "Failed to create the config directory."; | |
273 return false; | |
274 } | |
275 | |
276 return WriteConfig(config); | |
277 } | |
278 | |
279 bool StartDaemon() { | 268 bool StartDaemon() { |
280 DWORD access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | | 269 DWORD access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | |
281 SERVICE_START | SERVICE_STOP; | 270 SERVICE_START | SERVICE_STOP; |
282 ScopedScHandle service = OpenService(access); | 271 ScopedScHandle service = OpenService(access); |
283 if (!service.IsValid()) | 272 if (!service.IsValid()) |
284 return false; | 273 return false; |
285 | 274 |
286 // Change the service start type to 'auto'. | 275 // Change the service start type to 'auto'. |
287 if (!::ChangeServiceConfigW(service.Get(), | 276 if (!::ChangeServiceConfigW(service.Get(), |
288 SERVICE_NO_CHANGE, | 277 SERVICE_NO_CHANGE, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 InvokeCompletionCallback(done, StartDaemon()); | 466 InvokeCompletionCallback(done, StartDaemon()); |
478 } | 467 } |
479 | 468 |
480 scoped_refptr<DaemonController> DaemonController::Create() { | 469 scoped_refptr<DaemonController> DaemonController::Create() { |
481 scoped_ptr<DaemonController::Delegate> delegate( | 470 scoped_ptr<DaemonController::Delegate> delegate( |
482 new DaemonControllerDelegateWin()); | 471 new DaemonControllerDelegateWin()); |
483 return new DaemonController(delegate.Pass()); | 472 return new DaemonController(delegate.Pass()); |
484 } | 473 } |
485 | 474 |
486 } // namespace remoting | 475 } // namespace remoting |
OLD | NEW |