| OLD | NEW |
| 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 // This file implements the Windows service controlling Me2Me host processes | 5 // This file implements the Windows service controlling Me2Me host processes |
| 6 // running within user sessions. | 6 // running within user sessions. |
| 7 | 7 |
| 8 #include "remoting/host/win/host_service.h" | 8 #include "remoting/host/win/host_service.h" |
| 9 | 9 |
| 10 #include <sddl.h> | 10 #include <sddl.h> |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 | 270 |
| 271 i = next; | 271 i = next; |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 void HostService::CreateLauncher( | 275 void HostService::CreateLauncher( |
| 276 scoped_refptr<AutoThreadTaskRunner> task_runner) { | 276 scoped_refptr<AutoThreadTaskRunner> task_runner) { |
| 277 // Launch the I/O thread. | 277 // Launch the I/O thread. |
| 278 scoped_refptr<AutoThreadTaskRunner> io_task_runner = | 278 scoped_refptr<AutoThreadTaskRunner> io_task_runner = |
| 279 AutoThread::CreateWithType(kIoThreadName, task_runner, | 279 AutoThread::CreateWithType( |
| 280 MessageLoop::TYPE_IO); | 280 kIoThreadName, task_runner, base::MessageLoop::TYPE_IO); |
| 281 if (!io_task_runner) { | 281 if (!io_task_runner) { |
| 282 LOG(FATAL) << "Failed to start the I/O thread"; | 282 LOG(FATAL) << "Failed to start the I/O thread"; |
| 283 return; | 283 return; |
| 284 } | 284 } |
| 285 | 285 |
| 286 #if defined(REMOTING_MULTI_PROCESS) | 286 #if defined(REMOTING_MULTI_PROCESS) |
| 287 | 287 |
| 288 child_ = DaemonProcess::Create( | 288 child_ = DaemonProcess::Create( |
| 289 task_runner, | 289 task_runner, |
| 290 io_task_runner, | 290 io_task_runner, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 // Wait until the service thread completely exited to avoid concurrent | 324 // Wait until the service thread completely exited to avoid concurrent |
| 325 // teardown of objects registered with base::AtExitManager and object | 325 // teardown of objects registered with base::AtExitManager and object |
| 326 // destoyed by the service thread. | 326 // destoyed by the service thread. |
| 327 stopped_event_.Wait(); | 327 stopped_event_.Wait(); |
| 328 | 328 |
| 329 return kSuccessExitCode; | 329 return kSuccessExitCode; |
| 330 } | 330 } |
| 331 | 331 |
| 332 void HostService::RunAsServiceImpl() { | 332 void HostService::RunAsServiceImpl() { |
| 333 MessageLoop message_loop(MessageLoop::TYPE_UI); | 333 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
| 334 base::RunLoop run_loop; | 334 base::RunLoop run_loop; |
| 335 main_task_runner_ = message_loop.message_loop_proxy(); | 335 main_task_runner_ = message_loop.message_loop_proxy(); |
| 336 | 336 |
| 337 // Register the service control handler. | 337 // Register the service control handler. |
| 338 service_status_handle_ = RegisterServiceCtrlHandlerExW( | 338 service_status_handle_ = RegisterServiceCtrlHandlerExW( |
| 339 kWindowsServiceName, &HostService::ServiceControlHandler, this); | 339 kWindowsServiceName, &HostService::ServiceControlHandler, this); |
| 340 if (service_status_handle_ == 0) { | 340 if (service_status_handle_ == 0) { |
| 341 LOG_GETLASTERROR(ERROR) | 341 LOG_GETLASTERROR(ERROR) |
| 342 << "Failed to register the service control handler"; | 342 << "Failed to register the service control handler"; |
| 343 return; | 343 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 service_status.dwCurrentState = SERVICE_STOPPED; | 377 service_status.dwCurrentState = SERVICE_STOPPED; |
| 378 service_status.dwControlsAccepted = 0; | 378 service_status.dwControlsAccepted = 0; |
| 379 if (!SetServiceStatus(service_status_handle_, &service_status)) { | 379 if (!SetServiceStatus(service_status_handle_, &service_status)) { |
| 380 LOG_GETLASTERROR(ERROR) | 380 LOG_GETLASTERROR(ERROR) |
| 381 << "Failed to report service status to the service control manager"; | 381 << "Failed to report service status to the service control manager"; |
| 382 return; | 382 return; |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 int HostService::RunInConsole() { | 386 int HostService::RunInConsole() { |
| 387 MessageLoop message_loop(MessageLoop::TYPE_UI); | 387 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
| 388 base::RunLoop run_loop; | 388 base::RunLoop run_loop; |
| 389 main_task_runner_ = message_loop.message_loop_proxy(); | 389 main_task_runner_ = message_loop.message_loop_proxy(); |
| 390 | 390 |
| 391 int result = kInitializationFailed; | 391 int result = kInitializationFailed; |
| 392 | 392 |
| 393 // Initialize COM. | 393 // Initialize COM. |
| 394 base::win::ScopedCOMInitializer com_initializer; | 394 base::win::ScopedCOMInitializer com_initializer; |
| 395 if (!com_initializer.succeeded()) | 395 if (!com_initializer.succeeded()) |
| 396 return result; | 396 return result; |
| 397 | 397 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 int DaemonProcessMain() { | 512 int DaemonProcessMain() { |
| 513 HostService* service = HostService::GetInstance(); | 513 HostService* service = HostService::GetInstance(); |
| 514 if (!service->InitWithCommandLine(CommandLine::ForCurrentProcess())) { | 514 if (!service->InitWithCommandLine(CommandLine::ForCurrentProcess())) { |
| 515 return kUsageExitCode; | 515 return kUsageExitCode; |
| 516 } | 516 } |
| 517 | 517 |
| 518 return service->Run(); | 518 return service->Run(); |
| 519 } | 519 } |
| 520 | 520 |
| 521 } // namespace remoting | 521 } // namespace remoting |
| OLD | NEW |