Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: content/browser/browser_main_loop.cc

Issue 8596015: Revert 110710 - Add ChromeBrowserMainExtraParts for non main parts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/mock_content_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 0ae6be228c791384f600f7aed3aaa07f8d0dfb0d..2059d2a040107f26c1a5b6e2d2c5e0515554db80 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -158,9 +158,10 @@ BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters)
}
BrowserMainLoop::~BrowserMainLoop() {
- // Release/destroy parts here, before OleUninitialize() and before other
- // members are destroyed (in particular main_message_loop_).
- parts_.reset();
+ // Destroy added parts in reverse order.
+ for (int i = static_cast<int>(parts_list_.size())-1; i >= 0; --i)
+ delete parts_list_[i];
+ parts_list_.clear();
#if defined(OS_WIN)
OleUninitialize();
@@ -168,15 +169,15 @@ BrowserMainLoop::~BrowserMainLoop() {
}
void BrowserMainLoop::Init() {
- parts_.reset(
- GetContentClient()->browser()->CreateBrowserMainParts(parameters_));
+ GetContentClient()->browser()->CreateBrowserMainParts(
+ parameters_, &parts_list_);
}
// BrowserMainLoop stages ==================================================
void BrowserMainLoop::EarlyInitialization() {
- if (parts_.get())
- parts_->PreEarlyInitialization();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->PreEarlyInitialization();
#if defined(OS_WIN)
net::EnsureWinsockInit();
@@ -222,13 +223,13 @@ void BrowserMainLoop::EarlyInitialization() {
if (parsed_command_line_.HasSwitch(switches::kEnableTcpFastOpen))
net::set_tcp_fastopen_enabled(true);
- if (parts_.get())
- parts_->PostEarlyInitialization();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->PostEarlyInitialization();
}
void BrowserMainLoop::MainMessageLoopStart() {
- if (parts_.get())
- parts_->PreMainMessageLoopStart();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->PreMainMessageLoopStart();
#if defined(OS_WIN)
// If we're running tests (ui_task is non-null), then the ResourceBundle
@@ -259,24 +260,31 @@ void BrowserMainLoop::MainMessageLoopStart() {
system_message_window_.reset(new SystemMessageWindowWin);
#endif
- if (parts_.get())
- parts_->PostMainMessageLoopStart();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->PostMainMessageLoopStart();
}
void BrowserMainLoop::RunMainMessageLoopParts(
bool* completed_main_message_loop) {
- if (parts_.get())
- parts_->PreMainMessageLoopRun();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->PreMainMessageLoopRun();
TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, "");
// If the UI thread blocks, the whole UI is unresponsive.
// Do not allow disk IO from the UI thread.
base::ThreadRestrictions::SetIOAllowed(false);
+ // Iterate through each of the parts. If any of them ran the main
+ // message loop then they should return |true|. Otherwise
+ // BrowserMainLoop::MainMessageLoopRun loop will be run.
bool ran_main_loop = false;
- if (parts_.get())
- ran_main_loop = parts_->MainMessageLoopRun(&result_code_);
-
+ for (size_t i = 0; i < parts_list_.size(); ++i) {
+ int result_code = result_code_;
+ if (parts_list_[i]->MainMessageLoopRun(&result_code)) {
+ ran_main_loop = true;
+ result_code_ = result_code;
+ }
+ }
if (!ran_main_loop)
MainMessageLoopRun();
@@ -285,8 +293,8 @@ void BrowserMainLoop::RunMainMessageLoopParts(
if (completed_main_message_loop)
*completed_main_message_loop = true;
- if (parts_.get())
- parts_->PostMainMessageLoopRun();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->PostMainMessageLoopRun();
}
void BrowserMainLoop::InitializeMainThread() {
@@ -335,8 +343,8 @@ void BrowserMainLoop::InitializeToolkit() {
LOG_GETLASTERROR(FATAL);
#endif
- if (parts_.get())
- parts_->ToolkitInitialized();
+ for (size_t i = 0; i < parts_list_.size(); ++i)
+ parts_list_[i]->ToolkitInitialized();
}
void BrowserMainLoop::MainMessageLoopRun() {
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/mock_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698