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

Unified Diff: extensions/browser/api/api_resource_manager.h

Issue 431023003: Remove deprecated extension notifications from ApiResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « chrome/chrome_tests_unit.gypi ('k') | extensions/browser/api/api_resource_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/api_resource_manager.h
diff --git a/extensions/browser/api/api_resource_manager.h b/extensions/browser/api/api_resource_manager.h
index c2202788fe607472b79869d7d4845ef1299dd27e..0eaf36d73bb177653e8ec69f8544fdf3fe08bdf9 100644
--- a/extensions/browser/api/api_resource_manager.h
+++ b/extensions/browser/api/api_resource_manager.h
@@ -11,6 +11,7 @@
#include "base/lazy_instance.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
+#include "base/scoped_observer.h"
#include "base/threading/non_thread_safe.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/browser_thread.h"
@@ -19,6 +20,8 @@
#include "content/public/browser/notification_service.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_host.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/extension.h"
@@ -112,13 +115,12 @@ content::BrowserThread::ID TestThreadTraits<T>::thread_id_ =
template <class T, typename ThreadingTraits = NamedThreadTraits<T> >
class ApiResourceManager : public BrowserContextKeyedAPI,
public base::NonThreadSafe,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public ExtensionRegistryObserver {
public:
explicit ApiResourceManager(content::BrowserContext* context)
- : data_(new ApiResourceData()) {
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::NotificationService::AllSources());
+ : data_(new ApiResourceData()), extension_registry_observer_(this) {
+ extension_registry_observer_.Add(ExtensionRegistry::Get(context));
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
content::NotificationService::AllSources());
@@ -185,19 +187,17 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE {
- switch (type) {
- case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- std::string id = content::Details<extensions::UnloadedExtensionInfo>(
- details)->extension->id();
- data_->InitiateExtensionUnloadedCleanup(id);
- break;
- }
- case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
- ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
- data_->InitiateExtensionSuspendedCleanup(host->extension_id());
- break;
- }
- }
+ DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, type);
+ ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
+ data_->InitiateExtensionSuspendedCleanup(host->extension_id());
+ }
+
+ // ExtensionRegistryObserver:
+ virtual void OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) OVERRIDE {
+ data_->InitiateExtensionUnloadedCleanup(extension->id());
}
private:
@@ -398,6 +398,9 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
content::NotificationRegistrar registrar_;
scoped_refptr<ApiResourceData> data_;
+
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
};
// With WorkerPoolThreadTraits, ApiResourceManager can be used to manage the
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | extensions/browser/api/api_resource_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698