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

Unified Diff: chrome/browser/extensions/api/declarative/rules_registry_service.h

Issue 16087006: Revert "Revert 202751 "Change RulesRegistryService to use ProfileKeyedAPI."" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
Index: chrome/browser/extensions/api/declarative/rules_registry_service.h
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.h b/chrome/browser/extensions/api/declarative/rules_registry_service.h
index 4c846b85bb55f5eb0539ab090618c5488a4f8559..ee8833e3d49c85290740a4eb7b6de5484dc3de50 100644
--- a/chrome/browser/extensions/api/declarative/rules_registry_service.h
+++ b/chrome/browser/extensions/api/declarative/rules_registry_service.h
@@ -13,6 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h"
+#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -34,14 +35,21 @@ namespace extensions {
// This class owns all RulesRegistries implementations of an ExtensionService.
// This class lives on the UI thread.
-class RulesRegistryService : public content::NotificationObserver {
+class RulesRegistryService : public ProfileKeyedAPI,
+ public content::NotificationObserver {
public:
explicit RulesRegistryService(Profile* profile);
virtual ~RulesRegistryService();
// Unregisters refptrs to concrete RulesRegistries at other objects that were
// created by us so that the RulesRegistries can be released.
- void Shutdown();
+ virtual void Shutdown() OVERRIDE;
+
+ // ProfileKeyedAPI implementation.
+ static ProfileKeyedAPIFactory<RulesRegistryService>* GetFactoryInstance();
+
+ // Convenience method to get the RulesRegistryService for a profile.
+ static RulesRegistryService* Get(Profile* profile);
// Registers the default RulesRegistries used in Chromium.
void RegisterDefaultRulesRegistries();
@@ -62,6 +70,8 @@ class RulesRegistryService : public content::NotificationObserver {
// For testing.
void SimulateExtensionUnloaded(const std::string& extension_id);
private:
+ friend class ProfileKeyedAPIFactory<RulesRegistryService>;
+
// Maps event names to RuleRegistries that handle these events.
typedef std::map<std::string, scoped_refptr<RulesRegistry> > RulesRegistryMap;
@@ -75,6 +85,13 @@ class RulesRegistryService : public content::NotificationObserver {
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // ProfileKeyedAPI implementation.
+ static const char* service_name() {
+ return "RulesRegistryService";
+ }
+ static const bool kServiceHasOwnInstanceInIncognito = true;
+ static const bool kServiceIsNULLWhileTesting = true;
+
RulesRegistryMap rule_registries_;
// We own the parts of the registries which need to run on the UI thread.

Powered by Google App Engine
This is Rietveld 408576698