Commit 51abc7c8 authored by nancy's avatar nancy Committed by Commit Bot

Notify ExtensionApps when ArcAppListPrefs is destroyed.

When ArcAppListPrefs is destroyed, ExtensionApps doesn't clear the
arc_prefs_. So ExtensionApps still calls arc_prefs_ to remove itself from the
observer list, which could cause the memory issue, when ArcAppListPrefs is
deleted first. Update ArcAppListPrefs to notify the observer,
ExtensionApps, when ArcAppListPrefs is destroyed.
Note: ExtensionApps doesn't depend on ArcAppListPrefs, becuase even if no ARC
on the Chrome OS, ExtensionApps still exists.

BUG=1013850

Change-Id: I389e7b7c2d4e11a5af7f927a1595f75d7b2cc1f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857840
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705558}
parent cc8ef9a6
...@@ -597,6 +597,10 @@ void ExtensionApps::OnPackageListInitialRefreshed() { ...@@ -597,6 +597,10 @@ void ExtensionApps::OnPackageListInitialRefreshed() {
} }
} }
void ExtensionApps::OnArcAppListPrefsDestroyed() {
arc_prefs_ = nullptr;
}
// static // static
bool ExtensionApps::IsBlacklisted(const std::string& app_id) { bool ExtensionApps::IsBlacklisted(const std::string& app_id) {
// We blacklist (meaning we don't publish the app, in the App Service sense) // We blacklist (meaning we don't publish the app, in the App Service sense)
......
...@@ -119,6 +119,7 @@ class ExtensionApps : public apps::mojom::Publisher, ...@@ -119,6 +119,7 @@ class ExtensionApps : public apps::mojom::Publisher,
void OnPackageRemoved(const std::string& package_name, void OnPackageRemoved(const std::string& package_name,
bool uninstalled) override; bool uninstalled) override;
void OnPackageListInitialRefreshed() override; void OnPackageListInitialRefreshed() override;
void OnArcAppListPrefsDestroyed() override;
void Publish(apps::mojom::AppPtr app); void Publish(apps::mojom::AppPtr app);
......
...@@ -410,6 +410,9 @@ ArcAppListPrefs::ArcAppListPrefs( ...@@ -410,6 +410,9 @@ ArcAppListPrefs::ArcAppListPrefs(
} }
ArcAppListPrefs::~ArcAppListPrefs() { ArcAppListPrefs::~ArcAppListPrefs() {
for (auto& observer : observer_list_)
observer.OnArcAppListPrefsDestroyed();
arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get(); arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get();
if (!arc_session_manager) if (!arc_session_manager)
return; return;
......
...@@ -217,6 +217,9 @@ class ArcAppListPrefs : public KeyedService, ...@@ -217,6 +217,9 @@ class ArcAppListPrefs : public KeyedService,
virtual void OnInstallationFinished(const std::string& package_name, virtual void OnInstallationFinished(const std::string& package_name,
bool success) {} bool success) {}
// Notifies that ArcAppListPrefs is destroyed.
virtual void OnArcAppListPrefsDestroyed() {}
protected: protected:
virtual ~Observer() {} virtual ~Observer() {}
}; };
......
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