diff options
author | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-30 20:50:01 +0000 |
---|---|---|
committer | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-30 20:50:01 +0000 |
commit | 022614ef938eb2832aa5a4ba09ee0220b4837dec (patch) | |
tree | 6144c1b8b48ba889c03fdacd4e647e2a900c4190 /chrome/browser/browser_main.cc | |
parent | 7998c34f7003cc3da62278fa82068b70fe940d5c (diff) | |
download | chromium_src-022614ef938eb2832aa5a4ba09ee0220b4837dec.zip chromium_src-022614ef938eb2832aa5a4ba09ee0220b4837dec.tar.gz chromium_src-022614ef938eb2832aa5a4ba09ee0220b4837dec.tar.bz2 |
Provide and use auto startup/teardown for tracked objects
Avoid races with message loop teardown
r=nsylvain
Review URL: http://codereview.chromium.org/17023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_main.cc')
-rw-r--r-- | chrome/browser/browser_main.cc | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 4bea540..21be5b6 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -7,9 +7,9 @@ #include "base/command_line.h" #include "sandbox/src/sandbox.h" -// TODO(port): several win-only methods have been pulled out of this, but +// TODO(port): several win-only methods have been pulled out of this, but // BrowserMain() as a whole needs to be broken apart so that it's usable by -// other platforms. For now, it's just a stub. This is a serious work in +// other platforms. For now, it's just a stub. This is a serious work in // progress and should not be taken as an indication of a real refactoring. #if defined(OS_WIN) @@ -150,6 +150,13 @@ int BrowserMain(CommandLine &parsed_command_line, // TODO(beng, brettw): someday, break this out into sub functions with well // defined roles (e.g. pre/post-profile startup, etc). +#ifdef TRACK_ALL_TASK_OBJECTS + // Start tracking the creation and deletion of Task instance. + // This construction MUST be done before main_message_loop, so that it is + // destroyed after the main_message_loop. + tracked_objects::AutoTracking tracking_objects; +#endif + MessageLoop main_message_loop(MessageLoop::TYPE_UI); // Initialize the SystemMonitor @@ -264,12 +271,6 @@ int BrowserMain(CommandLine &parsed_command_line, // Initialize histogram statistics gathering system. StatisticsRecorder statistics; - // Start tracking the creation and deletion of Task instances - bool tracking_objects = false; -#ifdef TRACK_ALL_TASK_OBJECTS - tracking_objects = tracked_objects::ThreadData::StartTracking(true); -#endif - // Initialize the shared instance of user data manager. UserDataManager::Create(); @@ -487,21 +488,8 @@ int BrowserMain(CommandLine &parsed_command_line, // browser_shutdown takes care of deleting browser_process, so we need to // release it. browser_process.release(); - browser_shutdown::Shutdown(); - // The following teardown code will pacify Purify, but is not necessary for - // shutdown. Only list methods here that have no significant side effects - // and can be run in single threaded mode before terminating. -#ifndef NDEBUG // Don't call these in a Release build: they just waste time. - // The following should ONLY be called when in single threaded mode. It is - // unsafe to do this cleanup if other threads are still active. - // It is also very unnecessary, so I'm only doing this in debug to satisfy - // purify. - if (tracking_objects) - tracked_objects::ThreadData::ShutdownSingleThreadedCleanup(); -#endif // NDEBUG - return result_code; } |