Commit cf0f5818 authored by David Roger's avatar David Roger Committed by Commit Bot

Comment: BackgroundModeManager does not unregister ProfileAttributesStorage observer

This was found when auditing all observers of ProfileInfoCache to check
their unregistration.

Bug: None
Change-Id: I100a21b200bfd451db68c0ce5d3d33a0d97f7f9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519710
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Auto-Submit: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827224}
parent 7fdaa429
......@@ -268,6 +268,8 @@ BackgroundModeManager::BackgroundModeManager(
// Add self as an observer for the ProfileAttributesStorage so we know when
// profiles are deleted and their names change.
// This observer is never unregistered because the BackgroundModeManager
// outlives the profile storage.
profile_storage_->AddObserver(this);
UMA_HISTOGRAM_BOOLEAN("BackgroundMode.OnStartup.AutoLaunchState",
......
......@@ -425,6 +425,10 @@ void BrowserProcessImpl::StartTearDown() {
// can be destroyed.
UserManager::Hide();
#endif // !defined(OS_CHROMEOS)
// `profile_manager_` must be destroyed before `background_mode_manager_`,
// because the background mode manager does not stop observing profile
// changes at destruction (notifying the observers would cause a use-after-
// free).
profile_manager_.reset();
}
......
......@@ -316,6 +316,8 @@ class BrowserProcessImpl : public BrowserProcess,
std::unique_ptr<SystemNotificationHelper> system_notification_helper_;
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
// Must be destroyed after the profile manager, because it doesn't remove
// itself as a profile attributes storage observer on destruction.
std::unique_ptr<BackgroundModeManager> background_mode_manager_;
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment