summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 20:25:09 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 20:25:09 +0000
commit10d8398b778db2c47e712d184147db84e48d8d2a (patch)
tree69371d12e94fadca6d9de5c94a31adea2cf0c7a3
parent460d41d11d978aa2fcee2b335025e8828e632a99 (diff)
downloadchromium_src-10d8398b778db2c47e712d184147db84e48d8d2a.zip
chromium_src-10d8398b778db2c47e712d184147db84e48d8d2a.tar.gz
chromium_src-10d8398b778db2c47e712d184147db84e48d8d2a.tar.bz2
startup: move more platform-specific stuff into separate files
Move LowLevelShutdown into platform-specific files. Move the CAppModule bits into chrome_main_win.cc. Mostly refactoring. Semantic change: we now call CAppModule::Init() slightly earlier than before, and also logging::CleanupChromeLogging() slightly earlier. Review URL: http://codereview.chromium.org/6596055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76414 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chrome_main.cc35
-rw-r--r--chrome/app/chrome_main.h6
-rw-r--r--chrome/app/chrome_main_posix.cc9
-rw-r--r--chrome/app/chrome_main_win.cc16
4 files changed, 35 insertions, 31 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index 4473ac6..3454cc4 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -43,8 +43,7 @@
#if defined(OS_WIN)
#include <algorithm>
-#include <atlbase.h>
-#include <atlapp.h>
+#include <malloc.h>
#include "base/win/registry.h"
#include "sandbox/src/sandbox.h"
#include "tools/memory_watcher/memory_watcher.h"
@@ -124,8 +123,6 @@ bool LoadMemoryProfiler() {
return prof_module != NULL;
}
-CAppModule _Module;
-
#pragma optimize("", off)
// Handlers to silently dump the current process when there is an assert in
@@ -156,24 +153,6 @@ bool HasDeprecatedArguments(const std::wstring& command_line) {
#endif // defined(OS_WIN)
-// Perform last-second shutdown work. Partner of LowLevelInit().
-void LowLevelShutdown() {
-#if defined(OS_WIN)
-#ifdef _CRTDBG_MAP_ALLOC
- _CrtDumpMemoryLeaks();
-#endif // _CRTDBG_MAP_ALLOC
-
- _Module.Term();
-#endif
-
- logging::CleanupChromeLogging();
-
-#if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
- // TODO(mark): See the TODO(mark) at InitCrashReporter.
- DestructCrashReporter();
-#endif // OS_MACOSX && GOOGLE_CHROME_BUILD
-}
-
#if defined(OS_LINUX)
static void AdjustLinuxOOMScore(const std::string& process_type) {
const int kMiscScore = 7;
@@ -513,10 +492,12 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
char** argv = NULL;
#elif defined(OS_POSIX)
int ChromeMain(int argc, char** argv) {
+ // There is no HINSTANCE on non-Windows.
+ void* instance = NULL;
#endif
// LowLevelInit performs startup initialization before we
// e.g. allocate any memory. It must be the first call on startup.
- chrome_main::LowLevelInit();
+ chrome_main::LowLevelInit(instance);
// The exit manager is in charge of calling the dtors of singleton objects.
base::AtExitManager exit_manager;
@@ -701,10 +682,6 @@ int ChromeMain(int argc, char** argv) {
if (command_line.HasSwitch(switches::kMessageLoopHistogrammer))
MessageLoop::EnableHistogrammer(true);
-#if defined(OS_WIN)
- _Module.Init(NULL, instance);
-#endif
-
bool single_process =
#if defined (GOOGLE_CHROME_BUILD)
// This is an unsupported and not fully tested mode, so don't enable it for
@@ -827,7 +804,9 @@ int ChromeMain(int argc, char** argv) {
if (SubprocessNeedsResourceBundle(process_type))
ResourceBundle::CleanupSharedInstance();
- LowLevelShutdown();
+ logging::CleanupChromeLogging();
+
+ chrome_main::LowLevelShutdown();
return exit_code;
}
diff --git a/chrome/app/chrome_main.h b/chrome/app/chrome_main.h
index bb3a822..7fc8bfb 100644
--- a/chrome/app/chrome_main.h
+++ b/chrome/app/chrome_main.h
@@ -21,7 +21,11 @@ namespace chrome_main {
// Perform low-level initialization that occurs before we set up any
// objects or even consider the command line; for example, make us
// abort if we run out of memory.
-void LowLevelInit();
+// On Windows, hinstance is the instance parameter to ChromeMain (WinMain).
+void LowLevelInit(void* hinstance);
+
+// Perform last-second shutdown work. Partner of LowLevelInit().
+void LowLevelShutdown();
// Checks if the UserDataDir policy has been set and returns its value in the
// |user_data_dir| parameter. If no policy is set the parameter is not changed.
diff --git a/chrome/app/chrome_main_posix.cc b/chrome/app/chrome_main_posix.cc
index c7db9c0..0bfaced 100644
--- a/chrome/app/chrome_main_posix.cc
+++ b/chrome/app/chrome_main_posix.cc
@@ -39,7 +39,7 @@ void SetupSignalHandlers() {
namespace chrome_main {
-void LowLevelInit() {
+void LowLevelInit(void* instance) {
#if defined(OS_MACOSX)
// TODO(mark): Some of these things ought to be handled in
// chrome_exe_main_mac.mm. Under the current architecture, nothing
@@ -66,6 +66,13 @@ void LowLevelInit() {
#endif
}
+void LowLevelShutdown() {
+#if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
+ // TODO(mark): See the TODO(mark) at InitCrashReporter.
+ DestructCrashReporter();
+#endif // OS_MACOSX && GOOGLE_CHROME_BUILD
+}
+
#if !defined(OS_MACOSX)
// This policy is not implemented for Linux and ChromeOS. The win and mac ver-
// sions are implemented in the platform specific version of chrome_main.cc e.g.
diff --git a/chrome/app/chrome_main_win.cc b/chrome/app/chrome_main_win.cc
index 800e3f2..e10ae76 100644
--- a/chrome/app/chrome_main_win.cc
+++ b/chrome/app/chrome_main_win.cc
@@ -4,6 +4,8 @@
#include "chrome/app/chrome_main.h"
+#include <atlbase.h>
+#include <atlapp.h>
#include <malloc.h>
#include <new.h>
#include <shlobj.h>
@@ -21,6 +23,8 @@
namespace {
+CAppModule _Module;
+
#pragma optimize("", off)
// Handlers for invalid parameter and pure call. They generate a breakpoint to
// tell breakpad that it needs to dump the process.
@@ -90,8 +94,18 @@ bool LoadUserDataDirPolicyFromRegistry(HKEY hive, FilePath* user_data_dir) {
namespace chrome_main {
-void LowLevelInit() {
+void LowLevelInit(void* instance) {
RegisterInvalidParamHandler();
+
+ _Module.Init(NULL, static_cast<HINSTANCE>(instance));
+}
+
+void LowLevelShutdown() {
+#ifdef _CRTDBG_MAP_ALLOC
+ _CrtDumpMemoryLeaks();
+#endif // _CRTDBG_MAP_ALLOC
+
+ _Module.Term();
}
void CheckUserDataDirPolicy(FilePath* user_data_dir) {