OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/hi_res_timer_manager.h" | 5 #include "app/hi_res_timer_manager.h" |
6 #include "app/system_monitor.h" | 6 #include "app/system_monitor.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.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 "chrome/common/child_process.h" | 10 #include "chrome/common/child_process.h" |
11 #include "chrome/common/chrome_constants.h" | 11 #include "chrome/common/chrome_constants.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/logging_chrome.h" | 13 #include "chrome/common/logging_chrome.h" |
14 #include "chrome/common/main_function_params.h" | 14 #include "chrome/common/main_function_params.h" |
15 #include "chrome/worker/worker_thread.h" | 15 #include "chrome/worker/worker_thread.h" |
16 | 16 |
17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
18 #include "chrome/common/sandbox_init_wrapper.h" | 18 #include "chrome/common/sandbox_init_wrapper.h" |
19 #include "sandbox/src/sandbox.h" | 19 #include "sandbox/src/sandbox.h" |
20 #endif | 20 #endif |
21 | 21 |
22 // Mainline routine for running as the worker process. | 22 // Mainline routine for running as the worker process. |
23 int WorkerMain(const MainFunctionParams& parameters) { | 23 int WorkerMain(const MainFunctionParams& parameters) { |
24 // The main message loop of the worker process. | 24 // The main message loop of the worker process. |
25 MessageLoop main_message_loop; | 25 MessageLoop main_message_loop; |
26 std::wstring app_name = chrome::kBrowserAppName; | 26 PlatformThread::SetName("CrWorkerMain"); |
27 PlatformThread::SetName(WideToASCII(app_name + L"_WorkerMain").c_str()); | |
28 | 27 |
29 SystemMonitor system_monitor; | 28 SystemMonitor system_monitor; |
30 HighResolutionTimerManager hi_res_timer_manager; | 29 HighResolutionTimerManager hi_res_timer_manager; |
31 | 30 |
32 ChildProcess worker_process; | 31 ChildProcess worker_process; |
33 worker_process.set_main_thread(new WorkerThread()); | 32 worker_process.set_main_thread(new WorkerThread()); |
34 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
35 sandbox::TargetServices* target_services = | 34 sandbox::TargetServices* target_services = |
36 parameters.sandbox_info_.TargetServices(); | 35 parameters.sandbox_info_.TargetServices(); |
37 if (!target_services) | 36 if (!target_services) |
38 return false; | 37 return false; |
39 | 38 |
40 target_services->LowerToken(); | 39 target_services->LowerToken(); |
41 #endif | 40 #endif |
42 | 41 |
43 const CommandLine& parsed_command_line = parameters.command_line_; | 42 const CommandLine& parsed_command_line = parameters.command_line_; |
44 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { | 43 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { |
45 ChildProcess::WaitForDebugger(L"Worker"); | 44 ChildProcess::WaitForDebugger(L"Worker"); |
46 } | 45 } |
47 | 46 |
48 // Load the accelerator table from the browser executable and tell the | 47 // Load the accelerator table from the browser executable and tell the |
49 // message loop to use it when translating messages. | 48 // message loop to use it when translating messages. |
50 MessageLoop::current()->Run(); | 49 MessageLoop::current()->Run(); |
51 | 50 |
52 return 0; | 51 return 0; |
53 } | 52 } |
OLD | NEW |