Skip to content

Commit

Permalink
[Chrome OS] Delete NotificationPlatformBridge before g_browser_process
Browse files Browse the repository at this point in the history
is destroyed.

Bug: 787151
Change-Id: I66e39b0778f3507fba981c06bc9d3c2f13ba03d3
Reviewed-on: https://chromium-review.googlesource.com/782361
Reviewed-by: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519369}
  • Loading branch information
Evan Stade authored and Commit Bot committed Nov 27, 2017
1 parent 860d971 commit db1bf62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
9 changes: 6 additions & 3 deletions chrome/browser/chromeos/chrome_browser_main_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
chromeos::ResourceReporter::GetInstance()->StartMonitoring(
task_manager::TaskManagerInterface::GetTaskManager());

if (!base::FeatureList::IsEnabled(features::kNativeNotifications))
notification_client_.reset(NotificationPlatformBridge::Create());

ChromeBrowserMainPartsLinux::PreMainMessageLoopRun();
}

Expand Down Expand Up @@ -886,9 +889,6 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
message_center::MessageCenter::Get()->SetProductOSName(
l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME));

if (!base::FeatureList::IsEnabled(features::kNativeNotifications))
notification_client_.reset(NotificationPlatformBridge::Create());

// Register all installed components for regular update.
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock()},
Expand Down Expand Up @@ -1193,6 +1193,9 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
g_browser_process->platform_part()->browser_policy_connector_chromeos()->
PreShutdown();

// Close the notification client before destroying the profile manager.
notification_client_.reset();

// NOTE: Closes ash and destroys ash::Shell.
ChromeBrowserMainPartsLinux::PostMainMessageLoopRun();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <set>

#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "ui/base/layout.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
Expand All @@ -33,6 +31,7 @@ ArcApplicationNotifierControllerChromeOS::

std::vector<ash::mojom::NotifierUiDataPtr>
ArcApplicationNotifierControllerChromeOS::GetNotifierList(Profile* profile) {
DCHECK(!profile->IsOffTheRecord());
package_to_app_ids_.clear();
icons_.clear();
StopObserving();
Expand Down Expand Up @@ -112,14 +111,8 @@ void ArcApplicationNotifierControllerChromeOS::OnIconUpdated(ArcAppIcon* icon) {
void ArcApplicationNotifierControllerChromeOS::StopObserving() {
if (!last_profile_)
return;

// This is also called from the destructor during shutdown. In that case, the
// profile manager and the profiles are already destroyed. (see Issue 783538)
if (g_browser_process->profile_manager() &&
g_browser_process->profile_manager()->IsValidProfile(last_profile_)) {
ArcAppListPrefs* const app_list = ArcAppListPrefs::Get(last_profile_);
app_list->RemoveObserver(this);
}
ArcAppListPrefs* const app_list = ArcAppListPrefs::Get(last_profile_);
app_list->RemoveObserver(this);
last_profile_ = nullptr;
}

Expand Down

0 comments on commit db1bf62

Please sign in to comment.