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" | |
26 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
28 | 27 |
29 #if defined(OS_LINUX) | 28 #if defined(OS_LINUX) |
30 #include "chrome/app/breakpad_linux.h" | 29 #include "chrome/app/breakpad_linux.h" |
31 #endif | 30 #endif |
32 | 31 |
33 // This function provides some ways to test crash and assertion handling | 32 // This function provides some ways to test crash and assertion handling |
34 // behavior of the renderer. | 33 // behavior of the renderer. |
35 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { | 34 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // flag allowing us to attach a debugger. | 77 // flag allowing us to attach a debugger. |
79 // Do not move this function down since that would mean we can't easily debug | 78 // Do not move this function down since that would mean we can't easily debug |
80 // whatever occurs before it. | 79 // whatever occurs before it. |
81 HandleRendererErrorTestParameters(parsed_command_line); | 80 HandleRendererErrorTestParameters(parsed_command_line); |
82 | 81 |
83 RendererMainPlatformDelegate platform(parameters); | 82 RendererMainPlatformDelegate platform(parameters); |
84 | 83 |
85 StatsScope<StatsCounterTimer> | 84 StatsScope<StatsCounterTimer> |
86 startup_timer(chrome::Counters::renderer_main()); | 85 startup_timer(chrome::Counters::renderer_main()); |
87 | 86 |
88 // The main message loop of the renderer services doesn't have IO or UI tasks, | 87 // The main thread of the renderer services IO. |
89 // unless in-process-plugins is used. | 88 MessageLoopForIO main_message_loop; |
90 MessageLoop main_message_loop(RenderProcess::InProcessPlugins() ? | |
91 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT); | |
92 | |
93 std::wstring app_name = chrome::kBrowserAppName; | 89 std::wstring app_name = chrome::kBrowserAppName; |
94 PlatformThread::SetName(WideToASCII(app_name + L"_RendererMain").c_str()); | 90 PlatformThread::SetName(WideToASCII(app_name + L"_RendererMain").c_str()); |
95 | 91 |
96 // Initialize the SystemMonitor | 92 // Initialize the SystemMonitor |
97 base::SystemMonitor::Start(); | 93 base::SystemMonitor::Start(); |
98 | 94 |
99 platform.PlatformInitialize(); | 95 platform.PlatformInitialize(); |
100 | 96 |
101 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 97 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
102 platform.InitSandboxTests(no_sandbox); | 98 platform.InitSandboxTests(no_sandbox); |
(...skipping 10 matching lines...) Expand all Loading... |
113 // Ensure any field trials in browser are reflected into renderer. | 109 // Ensure any field trials in browser are reflected into renderer. |
114 if (parsed_command_line.HasSwitch(switches::kForceFieldTestNameAndValue)) { | 110 if (parsed_command_line.HasSwitch(switches::kForceFieldTestNameAndValue)) { |
115 std::string persistent(WideToASCII(parsed_command_line.GetSwitchValue( | 111 std::string persistent(WideToASCII(parsed_command_line.GetSwitchValue( |
116 switches::kForceFieldTestNameAndValue))); | 112 switches::kForceFieldTestNameAndValue))); |
117 bool ret = field_trial.StringAugmentsState(persistent); | 113 bool ret = field_trial.StringAugmentsState(persistent); |
118 DCHECK(ret); | 114 DCHECK(ret); |
119 } | 115 } |
120 | 116 |
121 { | 117 { |
122 RenderProcess render_process; | 118 RenderProcess render_process; |
123 render_process.set_main_thread(new RenderThread()); | |
124 bool run_loop = true; | 119 bool run_loop = true; |
125 if (!no_sandbox) { | 120 if (!no_sandbox) { |
126 run_loop = platform.EnableSandbox(); | 121 run_loop = platform.EnableSandbox(); |
127 } | 122 } |
128 | 123 |
129 platform.RunSandboxTests(); | 124 platform.RunSandboxTests(); |
130 | 125 |
131 startup_timer.Stop(); // End of Startup Time Measurement. | 126 startup_timer.Stop(); // End of Startup Time Measurement. |
132 | 127 |
133 if (run_loop) { | 128 if (run_loop) { |
134 // Load the accelerator table from the browser executable and tell the | 129 // Load the accelerator table from the browser executable and tell the |
135 // message loop to use it when translating messages. | 130 // message loop to use it when translating messages. |
136 if (pool) pool->Recycle(); | 131 if (pool) pool->Recycle(); |
137 MessageLoop::current()->Run(); | 132 MessageLoop::current()->Run(); |
138 } | 133 } |
139 } | 134 } |
140 platform.PlatformUninitialize(); | 135 platform.PlatformUninitialize(); |
141 return 0; | 136 return 0; |
142 } | 137 } |
OLD | NEW |