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/base_switches.h" | 5 #include "base/base_switches.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/hi_res_timer_manager.h" | 7 #include "base/hi_res_timer_manager.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/system_monitor/system_monitor.h" | 10 #include "base/system_monitor/system_monitor.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // Mainline routine for running as the worker process. | 23 // Mainline routine for running as the worker process. |
24 int WorkerMain(const MainFunctionParams& parameters) { | 24 int WorkerMain(const MainFunctionParams& parameters) { |
25 // The main message loop of the worker process. | 25 // The main message loop of the worker process. |
26 MessageLoop main_message_loop; | 26 MessageLoop main_message_loop; |
27 base::PlatformThread::SetName("CrWorkerMain"); | 27 base::PlatformThread::SetName("CrWorkerMain"); |
28 | 28 |
29 base::SystemMonitor system_monitor; | 29 base::SystemMonitor system_monitor; |
30 HighResolutionTimerManager hi_res_timer_manager; | 30 HighResolutionTimerManager hi_res_timer_manager; |
31 | 31 |
32 ChildProcess worker_process; | |
33 worker_process.set_main_thread(new WorkerThread()); | |
34 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
35 sandbox::TargetServices* target_services = | 33 sandbox::TargetServices* target_services = |
36 parameters.sandbox_info->target_services; | 34 parameters.sandbox_info->target_services; |
37 if (!target_services) | 35 if (!target_services) |
38 return false; | 36 return false; |
39 | 37 |
40 // Cause advapi32 to load before the sandbox is turned on. | 38 // Cause advapi32 to load before the sandbox is turned on. |
41 unsigned int dummy_rand; | 39 unsigned int dummy_rand; |
42 rand_s(&dummy_rand); | 40 rand_s(&dummy_rand); |
43 // Warm up language subsystems before the sandbox is turned on. | 41 // Warm up language subsystems before the sandbox is turned on. |
44 ::GetUserDefaultLangID(); | 42 ::GetUserDefaultLangID(); |
45 ::GetUserDefaultLCID(); | 43 ::GetUserDefaultLCID(); |
46 | 44 |
47 target_services->LowerToken(); | 45 target_services->LowerToken(); |
48 #endif | 46 #elif defined(OS_MAC) |
49 | 47 // On OS X, if the sandbox fails to initialize, something has gone terribly |
50 #if defined(OS_LINUX) | 48 // wrong and we should die. |
| 49 CHECK(InitializeSandbox()); |
| 50 #elif defined(OS_LINUX) |
| 51 // On Linux, the sandbox must be initialized early, before any thread is |
| 52 // created. |
51 InitializeSandbox(); | 53 InitializeSandbox(); |
52 #endif | 54 #endif |
| 55 ChildProcess worker_process; |
| 56 worker_process.set_main_thread(new WorkerThread()); |
53 | 57 |
54 const CommandLine& parsed_command_line = parameters.command_line; | 58 const CommandLine& parsed_command_line = parameters.command_line; |
55 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { | 59 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { |
56 ChildProcess::WaitForDebugger("Worker"); | 60 ChildProcess::WaitForDebugger("Worker"); |
57 } | 61 } |
58 | 62 |
59 // Load the accelerator table from the browser executable and tell the | 63 // Load the accelerator table from the browser executable and tell the |
60 // message loop to use it when translating messages. | 64 // message loop to use it when translating messages. |
61 MessageLoop::current()->Run(); | 65 MessageLoop::current()->Run(); |
62 | 66 |
63 return 0; | 67 return 0; |
64 } | 68 } |
65 | 69 |
66 } // namespace content | 70 } // namespace content |
OLD | NEW |