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 "chrome/app/chrome_main.h" | 5 #include "chrome/app/chrome_main.h" |
6 | 6 |
7 #include "app/app_paths.h" | 7 #include "app/app_paths.h" |
8 #include "app/app_switches.h" | 8 #include "app/app_switches.h" |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/debugger.h" | 11 #include "base/debug/debugger.h" |
12 #include "base/i18n/icu_util.h" | 12 #include "base/i18n/icu_util.h" |
13 #include "base/mac/scoped_nsautorelease_pool.h" | 13 #include "base/mac/scoped_nsautorelease_pool.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/metrics/stats_counters.h" | 15 #include "base/metrics/stats_counters.h" |
16 #include "base/metrics/stats_table.h" | 16 #include "base/metrics/stats_table.h" |
17 #include "base/nss_util.h" | 17 #include "base/nss_util.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/process_util.h" | 19 #include "base/process_util.h" |
20 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "chrome/browser/defaults.h" | 24 #include "chrome/browser/defaults.h" |
25 #include "chrome/browser/diagnostics/diagnostics_main.h" | 25 #include "chrome/browser/diagnostics/diagnostics_main.h" |
26 #include "chrome/browser/platform_util.h" | 26 #include "chrome/browser/platform_util.h" |
27 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_content_client.h" | 28 #include "chrome/common/chrome_content_client.h" |
| 29 #include "chrome/common/chrome_content_gpu_client.h" |
| 30 #include "chrome/common/chrome_content_plugin_client.h" |
29 #include "chrome/common/chrome_counters.h" | 31 #include "chrome/common/chrome_counters.h" |
30 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_paths_internal.h" | 33 #include "chrome/common/chrome_paths_internal.h" |
32 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/chrome_version_info.h" | 35 #include "chrome/common/chrome_version_info.h" |
34 #include "chrome/common/logging_chrome.h" | 36 #include "chrome/common/logging_chrome.h" |
35 #include "chrome/common/profiling.h" | 37 #include "chrome/common/profiling.h" |
36 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
37 #include "content/browser/renderer_host/render_process_host.h" | 39 #include "content/browser/renderer_host/render_process_host.h" |
38 #include "content/common/content_client.h" | 40 #include "content/common/content_client.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Enable the heap profiler if the appropriate command-line switch is | 206 // Enable the heap profiler if the appropriate command-line switch is |
205 // present, bailing out of the app we can't. | 207 // present, bailing out of the app we can't. |
206 void EnableHeapProfiler(const CommandLine& command_line) { | 208 void EnableHeapProfiler(const CommandLine& command_line) { |
207 #if defined(OS_WIN) | 209 #if defined(OS_WIN) |
208 if (command_line.HasSwitch(switches::kMemoryProfiling)) | 210 if (command_line.HasSwitch(switches::kMemoryProfiling)) |
209 if (!LoadMemoryProfiler()) | 211 if (!LoadMemoryProfiler()) |
210 exit(-1); | 212 exit(-1); |
211 #endif | 213 #endif |
212 } | 214 } |
213 | 215 |
214 void CommonSubprocessInit() { | 216 void CommonSubprocessInit(const std::string& process_type) { |
215 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
216 // HACK: Let Windows know that we have started. This is needed to suppress | 218 // HACK: Let Windows know that we have started. This is needed to suppress |
217 // the IDC_APPSTARTING cursor from being displayed for a prolonged period | 219 // the IDC_APPSTARTING cursor from being displayed for a prolonged period |
218 // while a subprocess is starting. | 220 // while a subprocess is starting. |
219 PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0); | 221 PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0); |
220 MSG msg; | 222 MSG msg; |
221 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); | 223 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); |
222 #endif | 224 #endif |
223 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 225 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
224 // Various things break when you're using a locale where the decimal | 226 // Various things break when you're using a locale where the decimal |
225 // separator isn't a period. See e.g. bugs 22782 and 39964. For | 227 // separator isn't a period. See e.g. bugs 22782 and 39964. For |
226 // all processes except the browser process (where we call system | 228 // all processes except the browser process (where we call system |
227 // APIs that may rely on the correct locale for formatting numbers | 229 // APIs that may rely on the correct locale for formatting numbers |
228 // when presenting them to the user), reset the locale for numeric | 230 // when presenting them to the user), reset the locale for numeric |
229 // formatting. | 231 // formatting. |
230 // Note that this is not correct for plugin processes -- they can | 232 // Note that this is not correct for plugin processes -- they can |
231 // surface UI -- but it's likely they get this wrong too so why not. | 233 // surface UI -- but it's likely they get this wrong too so why not. |
232 setlocale(LC_NUMERIC, "C"); | 234 setlocale(LC_NUMERIC, "C"); |
233 #endif | 235 #endif |
| 236 |
| 237 if (process_type == switches::kPluginProcess) { |
| 238 static chrome::ChromeContentPluginClient chrome_content_plugin_client; |
| 239 content::GetContentClient()->set_plugin(&chrome_content_plugin_client); |
| 240 } else if (process_type == switches::kGpuProcess) { |
| 241 static chrome::ChromeContentGpuClient chrome_content_gpu_client; |
| 242 content::GetContentClient()->set_gpu(&chrome_content_gpu_client); |
| 243 } |
234 } | 244 } |
235 | 245 |
236 // Returns true if this subprocess type needs the ResourceBundle initialized | 246 // Returns true if this subprocess type needs the ResourceBundle initialized |
237 // and resources loaded. | 247 // and resources loaded. |
238 bool SubprocessNeedsResourceBundle(const std::string& process_type) { | 248 bool SubprocessNeedsResourceBundle(const std::string& process_type) { |
239 return | 249 return |
240 #if defined(OS_WIN) || defined(OS_MACOSX) | 250 #if defined(OS_WIN) || defined(OS_MACOSX) |
241 // Windows needs resources for the default/null plugin. | 251 // Windows needs resources for the default/null plugin. |
242 // Mac needs them for the plugin process name. | 252 // Mac needs them for the plugin process name. |
243 process_type == switches::kPluginProcess || | 253 process_type == switches::kPluginProcess || |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; | 725 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; |
716 | 726 |
717 #if defined(OS_MACOSX) | 727 #if defined(OS_MACOSX) |
718 // Update the process name (need resources to get the strings, so | 728 // Update the process name (need resources to get the strings, so |
719 // only do this when ResourcesBundle has been initialized). | 729 // only do this when ResourcesBundle has been initialized). |
720 SetMacProcessName(process_type); | 730 SetMacProcessName(process_type); |
721 #endif // defined(OS_MACOSX) | 731 #endif // defined(OS_MACOSX) |
722 } | 732 } |
723 | 733 |
724 if (!process_type.empty()) | 734 if (!process_type.empty()) |
725 CommonSubprocessInit(); | 735 CommonSubprocessInit(process_type); |
726 | 736 |
727 // Initialize the sandbox for this process. | 737 // Initialize the sandbox for this process. |
728 SandboxInitWrapper sandbox_wrapper; | 738 SandboxInitWrapper sandbox_wrapper; |
729 bool initialize_sandbox = true; | 739 bool initialize_sandbox = true; |
730 | 740 |
731 #if defined(OS_WIN) | 741 #if defined(OS_WIN) |
732 sandbox_wrapper.SetServices(sandbox_info); | 742 sandbox_wrapper.SetServices(sandbox_info); |
733 #elif defined(OS_MACOSX) | 743 #elif defined(OS_MACOSX) |
734 // On OS X the renderer sandbox needs to be initialized later in the startup | 744 // On OS X the renderer sandbox needs to be initialized later in the startup |
735 // sequence in RendererMainPlatformDelegate::EnableSandbox(). | 745 // sequence in RendererMainPlatformDelegate::EnableSandbox(). |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 | 783 |
774 if (SubprocessNeedsResourceBundle(process_type)) | 784 if (SubprocessNeedsResourceBundle(process_type)) |
775 ResourceBundle::CleanupSharedInstance(); | 785 ResourceBundle::CleanupSharedInstance(); |
776 | 786 |
777 logging::CleanupChromeLogging(); | 787 logging::CleanupChromeLogging(); |
778 | 788 |
779 chrome_main::LowLevelShutdown(); | 789 chrome_main::LowLevelShutdown(); |
780 | 790 |
781 return exit_code; | 791 return exit_code; |
782 } | 792 } |
OLD | NEW |