OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/debug/debugger.h" | 5 #include "base/debug/debugger.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
| 9 #include "base/threading/platform_thread.h" |
9 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/main_function_params.h" | 12 #include "chrome/common/main_function_params.h" |
12 #include "chrome/common/sandbox_policy.h" | 13 #include "chrome/common/sandbox_policy.h" |
13 #include "chrome/common/service_process_util.h" | 14 #include "chrome/common/service_process_util.h" |
14 #include "chrome/service/cloud_print/cloud_print_proxy.h" | 15 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
15 #include "chrome/service/service_process.h" | 16 #include "chrome/service/service_process.h" |
16 | 17 |
17 // Mainline routine for running as the service process. | 18 // Mainline routine for running as the service process. |
18 int ServiceProcessMain(const MainFunctionParams& parameters) { | 19 int ServiceProcessMain(const MainFunctionParams& parameters) { |
19 // If there is already a service process running, quit now. | 20 // If there is already a service process running, quit now. |
20 if (!ServiceProcessState::GetInstance()->Initialize()) | 21 if (!ServiceProcessState::GetInstance()->Initialize()) |
21 return 0; | 22 return 0; |
22 | 23 |
23 MessageLoopForUI main_message_loop; | 24 MessageLoopForUI main_message_loop; |
24 if (parameters.command_line_.HasSwitch(switches::kWaitForDebugger)) { | 25 if (parameters.command_line_.HasSwitch(switches::kWaitForDebugger)) { |
25 base::debug::WaitForDebugger(60, true); | 26 base::debug::WaitForDebugger(60, true); |
26 } | 27 } |
27 | 28 |
28 PlatformThread::SetName("CrServiceMain"); | 29 base::PlatformThread::SetName("CrServiceMain"); |
29 | 30 |
30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
31 sandbox::BrokerServices* broker_services = | 32 sandbox::BrokerServices* broker_services = |
32 parameters.sandbox_info_.BrokerServices(); | 33 parameters.sandbox_info_.BrokerServices(); |
33 if (broker_services) | 34 if (broker_services) |
34 sandbox::InitBrokerServices(broker_services); | 35 sandbox::InitBrokerServices(broker_services); |
35 #endif // defined(OS_WIN) | 36 #endif // defined(OS_WIN) |
36 | 37 |
37 ServiceProcess service_process; | 38 ServiceProcess service_process; |
38 if (!service_process.Initialize(&main_message_loop, | 39 if (!service_process.Initialize(&main_message_loop, |
39 parameters.command_line_)) { | 40 parameters.command_line_)) { |
40 LOG(ERROR) << "Service process failed to initialize"; | 41 LOG(ERROR) << "Service process failed to initialize"; |
41 return 0; | 42 return 0; |
42 } | 43 } |
43 | 44 |
44 MessageLoop::current()->Run(); | 45 MessageLoop::current()->Run(); |
45 service_process.Teardown(); | 46 service_process.Teardown(); |
46 return 0; | 47 return 0; |
47 } | 48 } |
OLD | NEW |