OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "chrome/common/service_process_util.h" | 8 #include "chrome/common/service_process_util.h" |
9 #include "chrome/service/service_process.h" | 9 #include "chrome/service/service_process.h" |
10 #include "content/common/main_function_params.h" | 10 #include "content/common/main_function_params.h" |
11 | 11 |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include "content/common/sandbox_policy.h" | 13 #include "content/common/sandbox_policy.h" |
14 #elif defined(OS_MACOSX) | 14 #elif defined(OS_MACOSX) |
15 #include "content/common/chrome_application_mac.h" | 15 #include "chrome/service/chrome_service_application_mac.h" |
16 #endif // defined(OS_WIN) | 16 #endif // defined(OS_WIN) |
17 | 17 |
18 // Mainline routine for running as the service process. | 18 // Mainline routine for running as the service process. |
19 int ServiceProcessMain(const MainFunctionParams& parameters) { | 19 int ServiceProcessMain(const MainFunctionParams& parameters) { |
20 MessageLoopForUI main_message_loop; | 20 MessageLoopForUI main_message_loop; |
21 main_message_loop.set_thread_name("MainThread"); | 21 main_message_loop.set_thread_name("MainThread"); |
22 if (parameters.command_line_.HasSwitch(switches::kWaitForDebugger)) { | 22 if (parameters.command_line_.HasSwitch(switches::kWaitForDebugger)) { |
23 base::debug::WaitForDebugger(60, true); | 23 base::debug::WaitForDebugger(60, true); |
24 } | 24 } |
25 | 25 |
26 VLOG(1) << "Service process launched: " | 26 VLOG(1) << "Service process launched: " |
27 << parameters.command_line_.GetCommandLineString(); | 27 << parameters.command_line_.GetCommandLineString(); |
28 | 28 |
29 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
30 chrome_application_mac::RegisterCrApp(); | 30 chrome_service_application_mac::RegisterServiceCrApp(); |
31 #endif | 31 #endif |
32 | 32 |
33 base::PlatformThread::SetName("CrServiceMain"); | 33 base::PlatformThread::SetName("CrServiceMain"); |
34 | 34 |
35 // If there is already a service process running, quit now. | 35 // If there is already a service process running, quit now. |
36 scoped_ptr<ServiceProcessState> state(new ServiceProcessState); | 36 scoped_ptr<ServiceProcessState> state(new ServiceProcessState); |
37 if (!state->Initialize()) | 37 if (!state->Initialize()) |
38 return 0; | 38 return 0; |
39 | 39 |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 sandbox::BrokerServices* broker_services = | 41 sandbox::BrokerServices* broker_services = |
42 parameters.sandbox_info_.BrokerServices(); | 42 parameters.sandbox_info_.BrokerServices(); |
43 if (broker_services) | 43 if (broker_services) |
44 sandbox::InitBrokerServices(broker_services); | 44 sandbox::InitBrokerServices(broker_services); |
45 #endif // defined(OS_WIN) | 45 #endif // defined(OS_WIN) |
46 | 46 |
47 ServiceProcess service_process; | 47 ServiceProcess service_process; |
48 if (service_process.Initialize(&main_message_loop, | 48 if (service_process.Initialize(&main_message_loop, |
49 parameters.command_line_, | 49 parameters.command_line_, |
50 state.release())) { | 50 state.release())) { |
51 MessageLoop::current()->Run(); | 51 MessageLoop::current()->Run(); |
52 } else { | 52 } else { |
53 LOG(ERROR) << "Service process failed to initialize"; | 53 LOG(ERROR) << "Service process failed to initialize"; |
54 } | 54 } |
55 service_process.Teardown(); | 55 service_process.Teardown(); |
56 return 0; | 56 return 0; |
57 } | 57 } |
OLD | NEW |