 Chromium Code Reviews
 Chromium Code Reviews Issue 980663002:
  Fix crash on referencing deleted SignedInDevicesManager observer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 980663002:
  Fix crash on referencing deleted SignedInDevicesManager observer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_mana ger.h" | 5 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_mana ger.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 if (router) { | 108 if (router) { | 
| 109 router->RegisterObserver( | 109 router->RegisterObserver( | 
| 110 this, api::signed_in_devices::OnDeviceInfoChange::kEventName); | 110 this, api::signed_in_devices::OnDeviceInfoChange::kEventName); | 
| 111 } | 111 } | 
| 112 | 112 | 
| 113 // Register for unload event so we could clear all our listeners when | 113 // Register for unload event so we could clear all our listeners when | 
| 114 // extensions have unloaded. | 114 // extensions have unloaded. | 
| 115 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 115 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 
| 116 } | 116 } | 
| 117 | 117 | 
| 118 SignedInDevicesManager::~SignedInDevicesManager() {} | 118 SignedInDevicesManager::~SignedInDevicesManager() { | 
| 119 if (profile_) { | |
| 
Devlin
2015/03/09 16:35:43
Will profile_ ever be null?  We don't seem to chec
 
Rafał Chłodnicki
2015/03/09 20:46:43
But there are two constructors. One is for testing
 | |
| 120 extensions::EventRouter* router = extensions::EventRouter::Get(profile_); | |
| 
Devlin
2015/03/09 16:35:43
nit: remove extensions:: prefix (you're in the ext
 
Rafał Chłodnicki
2015/03/09 20:46:43
Done.
 | |
| 121 if (router) | |
| 122 router->UnregisterObserver(this); | |
| 
Devlin
2015/03/09 16:35:43
Shame we can't use a ScopedObserver for this... ah
 | |
| 123 } | |
| 124 } | |
| 119 | 125 | 
| 120 void SignedInDevicesManager::OnListenerAdded( | 126 void SignedInDevicesManager::OnListenerAdded( | 
| 121 const EventListenerInfo& details) { | 127 const EventListenerInfo& details) { | 
| 122 for (ScopedVector<SignedInDevicesChangeObserver>::const_iterator it = | 128 for (ScopedVector<SignedInDevicesChangeObserver>::const_iterator it = | 
| 123 change_observers_.begin(); | 129 change_observers_.begin(); | 
| 124 it != change_observers_.end(); | 130 it != change_observers_.end(); | 
| 125 ++it) { | 131 ++it) { | 
| 126 if ((*it)->extension_id() == details.extension_id) { | 132 if ((*it)->extension_id() == details.extension_id) { | 
| 127 DCHECK(false) <<"OnListenerAded fired twice for same extension"; | 133 DCHECK(false) <<"OnListenerAded fired twice for same extension"; | 
| 128 return; | 134 return; | 
| (...skipping 24 matching lines...) Expand all Loading... | |
| 153 } | 159 } | 
| 154 | 160 | 
| 155 void SignedInDevicesManager::OnExtensionUnloaded( | 161 void SignedInDevicesManager::OnExtensionUnloaded( | 
| 156 content::BrowserContext* browser_context, | 162 content::BrowserContext* browser_context, | 
| 157 const Extension* extension, | 163 const Extension* extension, | 
| 158 UnloadedExtensionInfo::Reason reason) { | 164 UnloadedExtensionInfo::Reason reason) { | 
| 159 RemoveChangeObserverForExtension(extension->id()); | 165 RemoveChangeObserverForExtension(extension->id()); | 
| 160 } | 166 } | 
| 161 | 167 | 
| 162 } // namespace extensions | 168 } // namespace extensions | 
| OLD | NEW |