Skip to content

Commit

Permalink
[content] Rename MainMessageLoopStart to CreateMainMessageLoop
Browse files Browse the repository at this point in the history
@qa: This CL is a no-op.

The meaning of this phase has diverged and become increasingly
confusing over the years.
This is not the timing at which the main message loop starts but rather
this is where it is created.

The previous term is easily confused with things like
  VariationsService::PerformPreMainMessageLoopStartup
  startup_metric_utils::RecordBrowserMainMessageLoopStart
that actually represent when the message loop starts.

This confusion has led to new calls being associated with the wrong
phase, e.g.
https://chromium-review.googlesource.com/c/chromium/src/+/2685139/6#message-d1f863178a7982698d1ff5a032b79e33e9e1d5ce

Bug: 1175074
Change-Id: I0535042abe69431501c9b3da3cfb2eae445fde0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2892278
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Owners-Override: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883468}
  • Loading branch information
Gabriel Charette authored and Chromium LUCI CQ committed May 17, 2021
1 parent 53710cf commit 09c6a96
Show file tree
Hide file tree
Showing 45 changed files with 103 additions and 103 deletions.
12 changes: 6 additions & 6 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -715,15 +715,15 @@ void ChromeBrowserMainParts::ToolkitInitialized() {
chrome_extra_parts_[i]->ToolkitInitialized();
}

void ChromeBrowserMainParts::PreMainMessageLoopStart() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopStart");
void ChromeBrowserMainParts::PreCreateMainMessageLoop() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateMainMessageLoop");

for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreMainMessageLoopStart();
chrome_extra_parts_[i]->PreCreateMainMessageLoop();
}

void ChromeBrowserMainParts::PostMainMessageLoopStart() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart");
void ChromeBrowserMainParts::PostCreateMainMessageLoop() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostCreateMainMessageLoop");

#if !defined(OS_ANDROID)
// Initialize the upgrade detector here after ChromeBrowserMainPartsChromeos
Expand All @@ -745,7 +745,7 @@ void ChromeBrowserMainParts::PostMainMessageLoopStart() {
device_event_log::Initialize(0 /* default max entries */);

for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopStart();
chrome_extra_parts_[i]->PostCreateMainMessageLoop();
}

int ChromeBrowserMainParts::PreCreateThreads() {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
int PreEarlyInitialization() override;
void PostEarlyInitialization() override;
void ToolkitInitialized() override;
void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
int PreCreateThreads() override;
void PostCreateThreads() override;
int PreMainMessageLoopRun() override;
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chrome_browser_main_extra_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class ChromeBrowserMainExtraParts {
// ToolkitInitialized methods.
virtual void ToolkitInitialized() {}

// MainMessageLoopStart methods.
virtual void PreMainMessageLoopStart() {}
virtual void PostMainMessageLoopStart() {}
// CreateMainMessageLoop methods.
virtual void PreCreateMainMessageLoop() {}
virtual void PostCreateMainMessageLoop() {}

// MainMessageLoopRun methods.
virtual void PreCreateThreads() {}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_extra_parts_ozone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void ChromeBrowserMainExtraPartsOzone::PreEarlyInitialization() {
#endif
}

void ChromeBrowserMainExtraPartsOzone::PostMainMessageLoopStart() {
void ChromeBrowserMainExtraPartsOzone::PostCreateMainMessageLoop() {
auto shutdown_cb = base::BindOnce([] {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// Force a crash so that a crash report is generated.
Expand All @@ -42,7 +42,7 @@ void ChromeBrowserMainExtraPartsOzone::PostMainMessageLoopStart() {
});
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
ui::OzonePlatform::GetInstance()->PostMainMessageLoopStart(
ui::OzonePlatform::GetInstance()->PostCreateMainMessageLoop(
std::move(shutdown_cb));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_extra_parts_ozone.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ChromeBrowserMainExtraPartsOzone : public ChromeBrowserMainExtraParts {
private:
// ChromeBrowserMainExtraParts overrides.
void PreEarlyInitialization() override;
void PostMainMessageLoopStart() override;
void PostCreateMainMessageLoop() override;
void PostMainMessageLoopRun() override;
};

Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/chrome_browser_main_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ void ChromeBrowserMainPartsLinux::PreProfileInit() {
ChromeBrowserMainPartsPosix::PreProfileInit();
}


void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
void ChromeBrowserMainPartsLinux::PostCreateMainMessageLoop() {
#if !BUILDFLAG(IS_CHROMEOS_ASH)
bluez::BluezDBusManager::Initialize(nullptr /* system_bus */);
#endif

ChromeBrowserMainPartsPosix::PostMainMessageLoopStart();
ChromeBrowserMainPartsPosix::PostCreateMainMessageLoop();
}

void ChromeBrowserMainPartsLinux::PostDestroyThreads() {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ChromeBrowserMainPartsLinux : public ChromeBrowserMainPartsPosix {

// ChromeBrowserMainParts overrides.
void PreProfileInit() override;
void PostMainMessageLoopStart() override;
void PostCreateMainMessageLoop() override;
void PostDestroyThreads() override;

private:
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ChromeBrowserMainPartsMac : public ChromeBrowserMainPartsPosix {

// BrowserParts overrides.
int PreEarlyInitialization() override;
void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
void PreProfileInit() override;
void PostProfileInit() override;

Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/chrome_browser_main_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
return ChromeBrowserMainPartsPosix::PreEarlyInitialization();
}

void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
void ChromeBrowserMainPartsMac::PreCreateMainMessageLoop() {
MacStartupProfiler::GetInstance()->Profile(
MacStartupProfiler::PRE_MAIN_MESSAGE_LOOP_START);
ChromeBrowserMainPartsPosix::PreMainMessageLoopStart();
ChromeBrowserMainPartsPosix::PreCreateMainMessageLoop();

// ChromeBrowserMainParts should have loaded the resource bundle by this
// point (needed to load the nib).
Expand Down Expand Up @@ -133,10 +133,10 @@
}
}

void ChromeBrowserMainPartsMac::PostMainMessageLoopStart() {
void ChromeBrowserMainPartsMac::PostCreateMainMessageLoop() {
MacStartupProfiler::GetInstance()->Profile(
MacStartupProfiler::POST_MAIN_MESSAGE_LOOP_START);
ChromeBrowserMainPartsPosix::PostMainMessageLoopStart();
ChromeBrowserMainPartsPosix::PostCreateMainMessageLoop();

if (base::FeatureList::IsEnabled(
net::features::kCertVerifierBuiltinFeature)) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ int ChromeBrowserMainPartsPosix::PreEarlyInitialization() {
return content::RESULT_CODE_NORMAL_EXIT;
}

void ChromeBrowserMainPartsPosix::PostMainMessageLoopStart() {
ChromeBrowserMainParts::PostMainMessageLoopStart();
void ChromeBrowserMainPartsPosix::PostCreateMainMessageLoop() {
ChromeBrowserMainParts::PostCreateMainMessageLoop();

// Exit in response to SIGINT, SIGTERM, etc.
InstallShutdownSignalHandlers(
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ChromeBrowserMainPartsPosix : public ChromeBrowserMainParts {

// content::BrowserMainParts overrides.
int PreEarlyInitialization() override;
void PostMainMessageLoopStart() override;
void PostCreateMainMessageLoop() override;

// ChromeBrowserMainParts overrides.
void ShowMissingLocaleMessageBox() override;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void ChromeBrowserMainPartsWin::ToolkitInitialized() {
gfx::win::SetGetMinimumFontSizeCallback(&GetMinimumFontSize);
}

void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() {
void ChromeBrowserMainPartsWin::PreCreateMainMessageLoop() {
// installer_util references strings that are normally compiled into
// setup.exe. In Chrome, these strings are in the locale files.
SetupInstallerUtilStrings();
Expand All @@ -594,7 +594,7 @@ void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() {
bool os_crypt_init = OSCrypt::Init(local_state);
DCHECK(os_crypt_init);

ChromeBrowserMainParts::PreMainMessageLoopStart();
ChromeBrowserMainParts::PreCreateMainMessageLoop();
if (!parameters().ui_task) {
// Make sure that we know how to handle exceptions from the message loop.
InitializeWindowProcExceptions();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts {

// BrowserParts overrides.
void ToolkitInitialized() override;
void PreMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
int PreCreateThreads() override;
void PostMainMessageLoopRun() override;

Expand Down
10 changes: 5 additions & 5 deletions chrome/browser/chromeos/chrome_browser_main_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,15 @@ int ChromeBrowserMainPartsChromeos::PreEarlyInitialization() {
return ChromeBrowserMainPartsLinux::PreEarlyInitialization();
}

void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() {
void ChromeBrowserMainPartsChromeos::PreCreateMainMessageLoop() {
// Initialize session manager in early stage in case others want to listen
// to session state change right after browser is started.
g_browser_process->platform_part()->InitializeSessionManager();

ChromeBrowserMainPartsLinux::PreMainMessageLoopStart();
ChromeBrowserMainPartsLinux::PreCreateMainMessageLoop();
}

void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
void ChromeBrowserMainPartsChromeos::PostCreateMainMessageLoop() {
// Used by ChromeOS components to retrieve the system token certificate
// database.
SystemTokenCertDbStorage::Initialize();
Expand All @@ -586,10 +586,10 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
// Need to be done after LoginState has been initialized in DBusServices().
::memory::MemoryKillsMonitor::Initialize();

ChromeBrowserMainPartsLinux::PostMainMessageLoopStart();
ChromeBrowserMainPartsLinux::PostCreateMainMessageLoop();
}

// Threads are initialized between MainMessageLoopStart and MainMessageLoopRun.
// Threads are initialized between CreateMainMessageLoop and MainMessageLoopRun.
// about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads.
int ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
network_change_manager_client_ = std::make_unique<NetworkChangeManagerClient>(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/chrome_browser_main_chromeos.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {

// ChromeBrowserMainParts overrides.
int PreEarlyInitialization() override;
void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
int PreMainMessageLoopRun() override;

// Stages called from PreMainMessageLoopRun.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ChromeBrowserExtraSetUp : public ChromeBrowserMainExtraParts {
explicit ChromeBrowserExtraSetUp(
policy::ChromeBrowserCloudManagementController::Observer* observer)
: observer_(observer) {}
void PreMainMessageLoopStart() override {
void PreCreateMainMessageLoop() override {
g_browser_process->browser_policy_connector()
->chrome_browser_cloud_management_controller()
->AddObserver(observer_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ ChromeBrowserMainExtraPartsPerformanceMonitor::
ChromeBrowserMainExtraPartsPerformanceMonitor::
~ChromeBrowserMainExtraPartsPerformanceMonitor() = default;

void ChromeBrowserMainExtraPartsPerformanceMonitor::PostMainMessageLoopStart() {
void ChromeBrowserMainExtraPartsPerformanceMonitor::
PostCreateMainMessageLoop() {
process_monitor_ = performance_monitor::ProcessMonitor::Create();
system_monitor_ = performance_monitor::SystemMonitor::Create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChromeBrowserMainExtraPartsPerformanceMonitor
const ChromeBrowserMainExtraPartsPerformanceMonitor&) = delete;

// ChromeBrowserMainExtraParts:
void PostMainMessageLoopStart() override;
void PostCreateMainMessageLoop() override;
void PreMainMessageLoopRun() override;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ChromeBrowserExtraSetUp : public ChromeBrowserMainExtraParts {
explicit ChromeBrowserExtraSetUp(
ChromeBrowserCloudManagementControllerObserver* observer)
: observer_(observer) {}
void PreMainMessageLoopStart() override {
void PreCreateMainMessageLoop() override {
g_browser_process->browser_policy_connector()
->chrome_browser_cloud_management_controller()
->AddObserver(observer_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() = default;

ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() = default;

void ChromeBrowserMainExtraPartsAsh::PreMainMessageLoopStart() {
void ChromeBrowserMainExtraPartsAsh::PreCreateMainMessageLoop() {
user_profile_loaded_observer_ = std::make_unique<UserProfileLoadedObserver>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
~ChromeBrowserMainExtraPartsAsh() override;

// Overridden from ChromeBrowserMainExtraParts:
void PreMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
void PreProfileInit() override;
void PostProfileInit() override;
void PostBrowserStart() override;
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/base/in_process_browser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class ChromeBrowserMainExtraPartsBrowserProcessInjection
ChromeBrowserMainExtraPartsBrowserProcessInjection() = default;

// ChromeBrowserMainExtraParts implementation
void PreMainMessageLoopStart() override {
void PreCreateMainMessageLoop() override {
// The real GeolocationManager initializes a CLLocationManager. It has
// been observed that when thousands of instances of this object are
// created, as happens when running browser tests, the CoreLocationAgent
Expand Down
4 changes: 2 additions & 2 deletions chromecast/browser/cast_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ content::BrowserContext* CastBrowserMainParts::browser_context() {
return cast_browser_process_->browser_context();
}

void CastBrowserMainParts::PreMainMessageLoopStart() {
void CastBrowserMainParts::PreCreateMainMessageLoop() {
// GroupedHistograms needs to be initialized before any threads are created
// to prevent race conditions between calls to Preregister and those threads
// attempting to collect metrics.
Expand All @@ -474,7 +474,7 @@ void CastBrowserMainParts::PreMainMessageLoopStart() {
#endif // !(defined(OS_ANDROID) || defined(OS_FUCHSIA))
}

void CastBrowserMainParts::PostMainMessageLoopStart() {
void CastBrowserMainParts::PostCreateMainMessageLoop() {
// Ensure CastMetricsHelper initialized on UI thread.
metrics::CastMetricsHelper::GetInstance();
}
Expand Down
4 changes: 2 additions & 2 deletions chromecast/browser/cast_browser_main_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class CastBrowserMainParts : public content::BrowserMainParts {
content::BrowserContext* browser_context();

// content::BrowserMainParts implementation:
void PreMainMessageLoopStart() override;
void PostMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
void PostCreateMainMessageLoop() override;
void ToolkitInitialized() override;
int PreCreateThreads() override;
int PreMainMessageLoopRun() override;
Expand Down
2 changes: 1 addition & 1 deletion components/session_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ SessionManager::Get() method gets the singleton like instance. The instance
in Chrome browser is ChromeSessionManager derived from SessionManager. This
is needed because SessionManager logic depends on policy code which is still
part of the browser. ChromeSessionManager is in browser/ and can access that.
The ChromeSessionManager instance is created in the PreMainMessageLoopStart
The ChromeSessionManager instance is created in the PreCreateMainMessageLoop
stage and destroyed in the PostMainMessageLoopRun.
2 changes: 1 addition & 1 deletion content/app/content_main_runner_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ int ContentMainRunnerImpl::RunBrowser(MainFunctionParams& main_params,
// Register the TaskExecutor for posting task to the BrowserThreads. It is
// incorrect to post to a BrowserThread before this point. This instantiates
// and binds the MessageLoopForUI on the main thread (but it's only labeled
// as BrowserThread::UI in BrowserMainLoop::MainMessageLoopStart).
// as BrowserThread::UI in BrowserMainLoop::CreateMainMessageLoop).
BrowserTaskExecutor::Create();

delegate_->PostEarlyInitialization(main_params.ui_task != nullptr);
Expand Down
23 changes: 12 additions & 11 deletions content/browser/browser_main_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,19 +629,20 @@ int BrowserMainLoop::EarlyInitialization() {
return RESULT_CODE_NORMAL_EXIT;
}

void BrowserMainLoop::PreMainMessageLoopStart() {
TRACE_EVENT0("startup",
"BrowserMainLoop::MainMessageLoopStart:PreMainMessageLoopStart");
void BrowserMainLoop::PreCreateMainMessageLoop() {
TRACE_EVENT0(
"startup",
"BrowserMainLoop::CreateMainMessageLoop:PreCreateMainMessageLoop");
if (parts_) {
parts_->PreMainMessageLoopStart();
parts_->PreCreateMainMessageLoop();
}
}

void BrowserMainLoop::MainMessageLoopStart() {
// DO NOT add more code here. Use PreMainMessageLoopStart() above or
// PostMainMessageLoopStart() below.
void BrowserMainLoop::CreateMainMessageLoop() {
// DO NOT add more code here. Use PreCreateMainMessageLoop() above or
// PostCreateMainMessageLoop() below.

TRACE_EVENT0("startup", "BrowserMainLoop::MainMessageLoopStart");
TRACE_EVENT0("startup", "BrowserMainLoop::CreateMainMessageLoop");

base::PlatformThread::SetName("CrBrowserMain");

Expand All @@ -653,8 +654,8 @@ void BrowserMainLoop::MainMessageLoopStart() {
BrowserThread::UI, base::ThreadTaskRunnerHandle::Get()));
}

void BrowserMainLoop::PostMainMessageLoopStart() {
TRACE_EVENT0("startup", "BrowserMainLoop::PostMainMessageLoopStart");
void BrowserMainLoop::PostCreateMainMessageLoop() {
TRACE_EVENT0("startup", "BrowserMainLoop::PostCreateMainMessageLoop");
{
TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SystemMonitor");
system_monitor_ = std::make_unique<base::SystemMonitor>();
Expand Down Expand Up @@ -706,7 +707,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
}

if (parts_)
parts_->PostMainMessageLoopStart();
parts_->PostCreateMainMessageLoop();

#if defined(OS_ANDROID)
{
Expand Down
Loading

0 comments on commit 09c6a96

Please sign in to comment.