summaryrefslogtreecommitdiffstats
path: root/chrome/app
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 22:13:25 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 22:13:25 +0000
commit639a51f52c68df1fcc3210ad7645b64f64a380f0 (patch)
tree9f1f5986d2a26eea4f4dfed56cf9b1483fa20e38 /chrome/app
parent8eb426aa9c321b1793ae48cd16714846a811acf0 (diff)
downloadchromium_src-639a51f52c68df1fcc3210ad7645b64f64a380f0.zip
chromium_src-639a51f52c68df1fcc3210ad7645b64f64a380f0.tar.gz
chromium_src-639a51f52c68df1fcc3210ad7645b64f64a380f0.tar.bz2
Only load resources for renderer, extension, and zygote processes
(and plugins processes on Windows). We used to always try to load them, even if we didn't use them. It would work fine if an update happened (because we didn't use them) and the files were replaced. Review URL: http://codereview.chromium.org/487001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34292 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r--chrome/app/chrome_dll_main.cc38
1 files changed, 29 insertions, 9 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index e78cec7..29beea1 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -32,6 +32,7 @@
#endif
#include "app/app_paths.h"
+#include "app/app_switches.h"
#include "app/resource_bundle.h"
#include "base/at_exit.h"
#include "base/command_line.h"
@@ -329,11 +330,6 @@ void EnableHeapProfiler(const CommandLine& parsed_command_line) {
}
void CommonSubprocessInit() {
- // Initialize ResourceBundle which handles files loaded from external
- // sources. The language should have been passed in to us from the
- // browser process as a command line flag.
- ResourceBundle::InitSharedInstance(std::wstring());
-
#if defined(OS_WIN)
// HACK: Let Windows know that we have started. This is needed to suppress
// the IDC_APPSTARTING cursor from being displayed for a prolonged period
@@ -344,6 +340,22 @@ void CommonSubprocessInit() {
#endif
}
+// Returns true if this subprocess type needs the ResourceBundle initialized
+// and resources loaded.
+bool SubprocessNeedsResourceBundle(const std::string& process_type) {
+ return
+#if defined(OS_WIN)
+ // Windows needs resources for the default/null plugin.
+ process_type == switches::kPluginProcess ||
+#endif
+#if defined(OS_LINUX)
+ // The zygote process opens the resources for the renderers.
+ process_type == switches::kZygoteProcess ||
+#endif
+ process_type == switches::kRendererProcess ||
+ process_type == switches::kExtensionProcess;
+}
+
} // namespace
#if defined(OS_WIN)
@@ -611,10 +623,19 @@ int ChromeMain(int argc, char** argv) {
}
#endif // NDEBUG
+ if (SubprocessNeedsResourceBundle(process_type)) {
+ // Initialize ResourceBundle which handles files loaded from external
+ // sources. The language should have been passed in to us from the
+ // browser process as a command line flag.
+ DCHECK(parsed_command_line.HasSwitch(switches::kLang) ||
+ process_type == switches::kZygoteProcess);
+ ResourceBundle::InitSharedInstance(std::wstring());
+ }
+
if (!process_type.empty())
CommonSubprocessInit();
-#if defined (OS_MACOSX)
+#if defined(OS_MACOSX)
// On OS X the renderer sandbox needs to be initialized later in the startup
// sequence in RendererMainPlatformDelegate::PlatformInitialize().
if (process_type != switches::kRendererProcess &&
@@ -651,7 +672,7 @@ int ChromeMain(int argc, char** argv) {
} else if (process_type == switches::kUtilityProcess) {
rv = UtilityMain(main_params);
} else if (process_type == switches::kProfileImportProcess) {
-#if defined (OS_MACOSX)
+#if defined(OS_MACOSX)
rv = ProfileImportMain(main_params);
#else
// TODO(port): Use OOP profile import - http://crbug.com/22142 .
@@ -727,9 +748,8 @@ int ChromeMain(int argc, char** argv) {
NOTREACHED() << "Unknown process type";
}
- if (!process_type.empty()) {
+ if (SubprocessNeedsResourceBundle(process_type))
ResourceBundle::CleanupSharedInstance();
- }
#if defined(OS_WIN)
#ifdef _CRTDBG_MAP_ALLOC