Index: content/browser/browser_main.cc |
diff --git a/content/browser/browser_main.cc b/content/browser/browser_main.cc |
index b0c9c19cde2182110146ece2dc57eae61870208d..e5a779df7bf1790c22a5c441fb58d08312b0de10 100644 |
--- a/content/browser/browser_main.cc |
+++ b/content/browser/browser_main.cc |
@@ -167,6 +167,28 @@ static void SetUpGLibLogHandler() { |
namespace content { |
+// BrowserParts |
+ |
+void BrowserParts::PreEarlyInitialization() { |
+} |
+ |
+void BrowserParts::PostEarlyInitialization() { |
+} |
+ |
+void BrowserParts::PreMainMessageLoopStart() { |
+} |
+ |
+void BrowserParts::PostMainMessageLoopStart() { |
+} |
+ |
+void BrowserParts::PreMainMessageLoopRun() { |
+} |
+ |
+void BrowserParts::PostMainMessageLoopRun() { |
+} |
+ |
+// BrowserMainParts |
+ |
BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) |
: parameters_(parameters), |
parsed_command_line_(parameters.command_line_), |
@@ -177,13 +199,30 @@ BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) |
} |
BrowserMainParts::~BrowserMainParts() { |
+ // Destroy added parts in reverse order. |
+ for (PartsList::reverse_iterator riter = added_parts_.rbegin(); |
+ riter != added_parts_.rend(); ++riter) { |
+ delete *riter; |
+ } |
+ added_parts_.clear(); |
+ |
#if defined(OS_WIN) |
OleUninitialize(); |
#endif |
} |
+void BrowserMainParts::AddParts(BrowserParts* parts) { |
+ added_parts_.push_back(parts); |
+} |
+ |
void BrowserMainParts::EarlyInitialization() { |
PreEarlyInitialization(); |
+ for (PartsList::iterator iter = added_parts_.begin(); |
+ iter != added_parts_.end(); ++iter) { |
+ (*iter)->PreEarlyInitialization(); |
+ } |
+ |
+ // Start watching for jank during shutdown. It gets disarmed when |
#if defined(OS_WIN) |
net::EnsureWinsockInit(); |
@@ -226,10 +265,18 @@ void BrowserMainParts::EarlyInitialization() { |
net::set_tcp_fastopen_enabled(true); |
PostEarlyInitialization(); |
+ for (PartsList::iterator iter = added_parts_.begin(); |
+ iter != added_parts_.end(); ++iter) { |
+ (*iter)->PostEarlyInitialization(); |
+ } |
} |
void BrowserMainParts::MainMessageLoopStart() { |
PreMainMessageLoopStart(); |
+ for (PartsList::iterator iter = added_parts_.begin(); |
+ iter != added_parts_.end(); ++iter) { |
+ (*iter)->PreMainMessageLoopStart(); |
+ } |
#if defined(OS_WIN) |
// If we're running tests (ui_task is non-null), then the ResourceBundle |
@@ -250,12 +297,20 @@ void BrowserMainParts::MainMessageLoopStart() { |
network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
PostMainMessageLoopStart(); |
+ for (PartsList::iterator iter = added_parts_.begin(); |
+ iter != added_parts_.end(); ++iter) { |
+ (*iter)->PostMainMessageLoopStart(); |
+ } |
} |
static bool g_exited_main_message_loop = false; |
void BrowserMainParts::RunMainMessageLoopParts() { |
PreMainMessageLoopRun(); |
+ for (PartsList::iterator iter = added_parts_.begin(); |
+ iter != added_parts_.end(); ++iter) { |
+ (*iter)->PreMainMessageLoopRun(); |
+ } |
TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
// If the UI thread blocks, the whole UI is unresponsive. |
@@ -267,6 +322,10 @@ void BrowserMainParts::RunMainMessageLoopParts() { |
g_exited_main_message_loop = true; |
PostMainMessageLoopRun(); |
+ for (PartsList::iterator iter = added_parts_.begin(); |
+ iter != added_parts_.end(); ++iter) { |
+ (*iter)->PostMainMessageLoopRun(); |
+ } |
} |
void BrowserMainParts::InitializeMainThread() { |
@@ -287,7 +346,8 @@ void BrowserMainParts::InitializeToolkit() { |
// TODO(evan): this function is rather subtle, due to the variety |
// of intersecting ifdefs we have. To keep it easy to follow, there |
// are no #else branches on any #ifs. |
- |
+ // TODO(stevenjb): Move platform specific code into platform specific Parts |
+ // (Need to add InitializeToolkit stage to BrowserParts). |
#if defined(OS_LINUX) |
// We want to call g_thread_init(), but in some codepaths (tests) it |
// is possible it has already been called. In older versions of |
@@ -333,20 +393,7 @@ void BrowserMainParts::InitializeToolkit() { |
ToolkitInitialized(); |
} |
-void BrowserMainParts::PreEarlyInitialization() { |
-} |
- |
-void BrowserMainParts::PostEarlyInitialization() { |
-} |
- |
-void BrowserMainParts::PreMainMessageLoopStart() { |
-} |
- |
-void BrowserMainParts::PostMainMessageLoopStart() { |
-} |
- |
-void BrowserMainParts::PreMainMessageLoopRun() { |
-} |
+// BrowserMainParts implementation |
void BrowserMainParts::MainMessageLoopRun() { |
if (parameters().ui_task) |
@@ -359,9 +406,6 @@ void BrowserMainParts::MainMessageLoopRun() { |
#endif |
} |
-void BrowserMainParts::PostMainMessageLoopRun() { |
-} |
- |
void BrowserMainParts::ToolkitInitialized() { |
} |