Move HistogramSynchronizer initialization to BrowserMainParts.

This allows HistogramSynchronizer to be released before main_message_loop_ (which it accesses in its destructor).
A change that caused BrowserParts to be destroyed explicitly before the end of BrowserMain (and thus before local variable destruction) introduced the associated crash bug.


BUG=chromium:95240
TEST=Ensure Chrome exits cleanly (especially on Mac and Windows).


Review URL: http://codereview.chromium.org/7832010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99522 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_main.h b/chrome/browser/browser_main.h
index 09a41f0c..ec1dc6e 100644
--- a/chrome/browser/browser_main.h
+++ b/chrome/browser/browser_main.h
@@ -14,6 +14,7 @@
 
 class BrowserThread;
 class CommandLine;
+class HistogramSynchronizer;
 class FieldTrialSynchronizer;
 class HighResolutionTimerManager;
 struct MainFunctionParams;
@@ -89,6 +90,10 @@
   void EarlyInitialization();
   void MainMessageLoopStart();
 
+  // Constructs HistogramSynchronizer which gets released early (before
+  // main_message_loop_).
+  void SetupHistogramSynchronizer();
+
   // Constructs metrics service and does related initialization, including
   // creation of field trials. Call only after labs have been converted to
   // switches.
@@ -182,6 +187,11 @@
   scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
   scoped_ptr<BrowserThread> main_thread_;
 
+  // Members initialized after / released before main_message_loop_ ------------
+
+  // Initialized in SetupHistogramSynchronizer.
+  scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
+
   // Initialized in SetupMetricsAndFieldTrials.
   scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;