| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "app/resource_bundle.h" | 6 #include "app/resource_bundle.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/field_trial.h" | 8 #include "base/field_trial.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/platform_thread.h" | 12 #include "base/platform_thread.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/scoped_nsautorelease_pool.h" | 14 #include "base/scoped_nsautorelease_pool.h" |
| 15 #include "base/stats_counters.h" | 15 #include "base/stats_counters.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/system_monitor.h" | 17 #include "base/system_monitor.h" |
| 18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_counters.h" | 19 #include "chrome/common/chrome_counters.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/logging_chrome.h" | 21 #include "chrome/common/logging_chrome.h" |
| 22 #include "chrome/common/main_function_params.h" | 22 #include "chrome/common/main_function_params.h" |
| 23 #include "chrome/renderer/renderer_main_platform_delegate.h" | 23 #include "chrome/renderer/renderer_main_platform_delegate.h" |
| 24 #include "chrome/renderer/render_process.h" | 24 #include "chrome/renderer/render_process.h" |
| 25 #include "chrome/renderer/render_thread.h" |
| 25 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| 26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 27 | 28 |
| 28 #if defined(OS_LINUX) | 29 #if defined(OS_LINUX) |
| 29 #include "chrome/app/breakpad_linux.h" | 30 #include "chrome/app/breakpad_linux.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if defined(OS_POSIX) | 33 #if defined(OS_POSIX) |
| 33 #include <signal.h> | 34 #include <signal.h> |
| 34 | 35 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // flag allowing us to attach a debugger. | 90 // flag allowing us to attach a debugger. |
| 90 // Do not move this function down since that would mean we can't easily debug | 91 // Do not move this function down since that would mean we can't easily debug |
| 91 // whatever occurs before it. | 92 // whatever occurs before it. |
| 92 HandleRendererErrorTestParameters(parsed_command_line); | 93 HandleRendererErrorTestParameters(parsed_command_line); |
| 93 | 94 |
| 94 RendererMainPlatformDelegate platform(parameters); | 95 RendererMainPlatformDelegate platform(parameters); |
| 95 | 96 |
| 96 StatsScope<StatsCounterTimer> | 97 StatsScope<StatsCounterTimer> |
| 97 startup_timer(chrome::Counters::renderer_main()); | 98 startup_timer(chrome::Counters::renderer_main()); |
| 98 | 99 |
| 99 // The main thread of the renderer services IO. | 100 // The main message loop of the renderer services doesn't have IO or UI tasks, |
| 100 MessageLoopForIO main_message_loop; | 101 // unless in-process-plugins is used. |
| 102 MessageLoop main_message_loop(RenderProcess::InProcessPlugins() ? |
| 103 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT); |
| 104 |
| 101 std::wstring app_name = chrome::kBrowserAppName; | 105 std::wstring app_name = chrome::kBrowserAppName; |
| 102 PlatformThread::SetName(WideToASCII(app_name + L"_RendererMain").c_str()); | 106 PlatformThread::SetName(WideToASCII(app_name + L"_RendererMain").c_str()); |
| 103 | 107 |
| 104 // Initialize the SystemMonitor | 108 // Initialize the SystemMonitor |
| 105 base::SystemMonitor::Start(); | 109 base::SystemMonitor::Start(); |
| 106 | 110 |
| 107 platform.PlatformInitialize(); | 111 platform.PlatformInitialize(); |
| 108 | 112 |
| 109 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 113 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
| 110 platform.InitSandboxTests(no_sandbox); | 114 platform.InitSandboxTests(no_sandbox); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 121 // Ensure any field trials in browser are reflected into renderer. | 125 // Ensure any field trials in browser are reflected into renderer. |
| 122 if (parsed_command_line.HasSwitch(switches::kForceFieldTestNameAndValue)) { | 126 if (parsed_command_line.HasSwitch(switches::kForceFieldTestNameAndValue)) { |
| 123 std::string persistent(WideToASCII(parsed_command_line.GetSwitchValue( | 127 std::string persistent(WideToASCII(parsed_command_line.GetSwitchValue( |
| 124 switches::kForceFieldTestNameAndValue))); | 128 switches::kForceFieldTestNameAndValue))); |
| 125 bool ret = field_trial.StringAugmentsState(persistent); | 129 bool ret = field_trial.StringAugmentsState(persistent); |
| 126 DCHECK(ret); | 130 DCHECK(ret); |
| 127 } | 131 } |
| 128 | 132 |
| 129 { | 133 { |
| 130 RenderProcess render_process; | 134 RenderProcess render_process; |
| 135 render_process.set_main_thread(new RenderThread()); |
| 131 bool run_loop = true; | 136 bool run_loop = true; |
| 132 if (!no_sandbox) { | 137 if (!no_sandbox) { |
| 133 run_loop = platform.EnableSandbox(); | 138 run_loop = platform.EnableSandbox(); |
| 134 } | 139 } |
| 135 | 140 |
| 136 platform.RunSandboxTests(); | 141 platform.RunSandboxTests(); |
| 137 | 142 |
| 138 startup_timer.Stop(); // End of Startup Time Measurement. | 143 startup_timer.Stop(); // End of Startup Time Measurement. |
| 139 | 144 |
| 140 if (run_loop) { | 145 if (run_loop) { |
| 141 // Load the accelerator table from the browser executable and tell the | 146 // Load the accelerator table from the browser executable and tell the |
| 142 // message loop to use it when translating messages. | 147 // message loop to use it when translating messages. |
| 143 if (pool) pool->Recycle(); | 148 if (pool) pool->Recycle(); |
| 144 MessageLoop::current()->Run(); | 149 MessageLoop::current()->Run(); |
| 145 } | 150 } |
| 146 } | 151 } |
| 147 platform.PlatformUninitialize(); | 152 platform.PlatformUninitialize(); |
| 148 return 0; | 153 return 0; |
| 149 } | 154 } |
| OLD | NEW |