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

Unified Diff: chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc

Issue 980663002: Fix crash on referencing deleted SignedInDevicesManager observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit Created 5 years, 9 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
index 2dcc91cc0298313ad383637e693e7d2deebbfc9b..6ad2c2fe1ad2c323875f5dad6db4e763273f89f6 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
@@ -104,7 +104,7 @@ SignedInDevicesManager::SignedInDevicesManager()
SignedInDevicesManager::SignedInDevicesManager(content::BrowserContext* context)
: profile_(Profile::FromBrowserContext(context)),
extension_registry_observer_(this) {
- extensions::EventRouter* router = extensions::EventRouter::Get(profile_);
+ EventRouter* router = EventRouter::Get(profile_);
if (router) {
router->RegisterObserver(
this, api::signed_in_devices::OnDeviceInfoChange::kEventName);
@@ -115,7 +115,13 @@ SignedInDevicesManager::SignedInDevicesManager(content::BrowserContext* context)
extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
}
-SignedInDevicesManager::~SignedInDevicesManager() {}
+SignedInDevicesManager::~SignedInDevicesManager() {
+ if (profile_) {
+ EventRouter* router = EventRouter::Get(profile_);
+ if (router)
+ router->UnregisterObserver(this);
+ }
+}
void SignedInDevicesManager::OnListenerAdded(
const EventListenerInfo& details) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698