Index: chrome/browser/browser_main.h |
=================================================================== |
--- chrome/browser/browser_main.h (revision 99756) |
+++ chrome/browser/browser_main.h (working copy) |
@@ -8,88 +8,26 @@ |
#include "base/basictypes.h" |
#include "base/gtest_prod_util.h" |
-#include "base/memory/scoped_ptr.h" |
#include "base/metrics/field_trial.h" |
#include "base/tracked_objects.h" |
+#include "content/browser/browser_main.h" |
-class BrowserThread; |
-class CommandLine; |
-class HistogramSynchronizer; |
class FieldTrialSynchronizer; |
-class HighResolutionTimerManager; |
-struct MainFunctionParams; |
-class MessageLoop; |
+class HistogramSynchronizer; |
class MetricsService; |
class PrefService; |
+class ShutdownWatcherHelper; |
-namespace base { |
-class SystemMonitor; |
-} |
- |
-namespace net { |
-class NetworkChangeNotifier; |
-} |
- |
namespace chrome_browser { |
// For use by ShowMissingLocaleMessageBox. |
extern const char kMissingLocaleDataTitle[]; |
extern const char kMissingLocaleDataMessage[]; |
} |
-// BrowserMainParts: |
-// This class contains different "stages" to be executed in |BrowserMain()|, |
-// mostly initialization. This is made into a class rather than just functions |
-// so each stage can create and maintain state. Each part is represented by a |
-// single method (e.g., "EarlyInitialization()"), which does the following: |
-// - calls a method (e.g., "PreEarlyInitialization()") which individual |
-// platforms can override to provide platform-specific code which is to be |
-// executed before the common code; |
-// - calls various methods for things common to all platforms (for that given |
-// stage); and |
-// - calls a method (e.g., "PostEarlyInitialization()") for platform-specific |
-// code to be called after the common code. |
-// As indicated above, platforms should override the default "Pre...()" and |
-// "Post...()" methods when necessary; they need not call the superclass's |
-// implementation (which is empty). |
-// |
-// Parts: |
-// - EarlyInitialization: things which should be done as soon as possible on |
-// program start (such as setting up signal handlers) and things to be done |
-// at some generic time before the start of the main message loop. |
-// - MainMessageLoopStart: things beginning with the start of the main message |
-// loop and ending with initialization of the main thread; platform-specific |
-// things which should be done immediately before the start of the main |
-// message loop should go in |PreMainMessageLoopStart()|. |
-// - (more to come) |
-// |
-// How to add stuff (to existing parts): |
-// - Figure out when your new code should be executed. What must happen |
-// before/after your code is executed? Are there performance reasons for |
-// running your code at a particular time? Document these things! |
-// - Split out any platform-specific bits. Please avoid #ifdefs it at all |
-// possible. You have two choices for platform-specific code: (1) Execute it |
-// from one of the platform-specific |Pre/Post...()| methods; do this if the |
-// code is unique to a platform type. Or (2) execute it from one of the |
-// "parts" (e.g., |EarlyInitialization()|) and provide platform-specific |
-// implementations of your code (in a virtual method); do this if you need to |
-// provide different implementations across most/all platforms. |
-// - Unless your new code is just one or two lines, put it into a separate |
-// method with a well-defined purpose. (Likewise, if you're adding to an |
-// existing chunk which makes it longer than one or two lines, please move |
-// the code out into a separate method.) |
-class BrowserMainParts { |
+class ChromeBrowserMainParts : public content::BrowserMainParts { |
public: |
- // This static method is to be implemented by each platform and should |
- // instantiate the appropriate subclass. |
- static BrowserMainParts* CreateBrowserMainParts( |
- const MainFunctionParams& parameters); |
+ virtual ~ChromeBrowserMainParts(); |
- virtual ~BrowserMainParts(); |
- |
- // Parts to be called by |BrowserMain()|. |
- void EarlyInitialization(); |
- void MainMessageLoopStart(); |
- |
// Constructs HistogramSynchronizer which gets released early (before |
// main_message_loop_). |
void SetupHistogramSynchronizer(); |
@@ -102,25 +40,12 @@ |
PrefService* local_state); |
protected: |
- explicit BrowserMainParts(const MainFunctionParams& parameters); |
+ explicit ChromeBrowserMainParts(const MainFunctionParams& parameters); |
- // Accessors for data members (below) ---------------------------------------- |
- const MainFunctionParams& parameters() const { |
- return parameters_; |
- } |
- const CommandLine& parsed_command_line() const { |
- return parsed_command_line_; |
- } |
- MessageLoop& main_message_loop() const { |
- return *main_message_loop_; |
- } |
+ virtual void PostMainMessageLoopStart() OVERRIDE; |
+ virtual void ToolkitInitialized() OVERRIDE; |
- // Methods to be overridden to provide platform-specific code; these |
- // correspond to the "parts" above. |
- virtual void PreEarlyInitialization() {} |
- virtual void PostEarlyInitialization() {} |
- virtual void PreMainMessageLoopStart() {} |
- virtual void PostMainMessageLoopStart() {} |
+ virtual int TemporaryContinue() OVERRIDE; |
private: |
// Methods for |EarlyInitialization()| --------------------------------------- |
@@ -147,13 +72,6 @@ |
// A/B test for using a different host prefix in Google search suggest. |
void SuggestPrefixFieldTrial(); |
- // Used to initialize NSPR where appropriate. |
- virtual void InitializeSSL() = 0; |
- |
- // Methods for |MainMessageLoopStart()| -------------------------------------- |
- |
- void InitializeMainThread(); |
- |
// Methods for |SetupMetricsAndFieldTrials()| -------------------------------- |
static MetricsService* InitializeMetrics( |
@@ -166,8 +84,10 @@ |
// Members initialized on construction --------------------------------------- |
- const MainFunctionParams& parameters_; |
- const CommandLine& parsed_command_line_; |
+ // Create ShutdownWatcherHelper object for watching jank during shutdown. |
+ // Please keep |shutdown_watcher| as the first object constructed, and hence |
+ // it is destroyed last. |
+ scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_; |
#if defined(TRACK_ALL_TASK_OBJECTS) |
// Creating this object starts tracking the creation and deletion of Task |
@@ -180,13 +100,6 @@ |
// SetupMetricsAndFieldTrials is called. |
scoped_ptr<base::FieldTrialList> field_trial_list_; |
- // Members initialized in |MainMessageLoopStart()| --------------------------- |
- scoped_ptr<MessageLoop> main_message_loop_; |
- scoped_ptr<base::SystemMonitor> system_monitor_; |
- scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; |
- scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
- scoped_ptr<BrowserThread> main_thread_; |
- |
// Members initialized after / released before main_message_loop_ ------------ |
// Initialized in SetupHistogramSynchronizer. |
@@ -198,14 +111,9 @@ |
FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket); |
FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random); |
FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid); |
- DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); |
+ DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); |
}; |
- |
-// Perform platform-specific work that needs to be done after the main event |
-// loop has ended. |
-void DidEndMainMessageLoop(); |
- |
// Records the conditions that can prevent Breakpad from generating and |
// sending crash reports. The presence of a Breakpad handler (after |
// attempting to initialize crash reporting) and the presence of a debugger |