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

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

Issue 10560013: Persist declarative rules to the extension state store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RegisterKey Created 8 years, 6 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_with_cache.h
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_with_cache.h b/chrome/browser/extensions/api/declarative/rules_registry_with_cache.h
index 4ad4e510c83eceb55657d8b970d70e7e07e544bb..866df6b6cf734f4afb0fa050ae5fd1ebc977a30c 100644
--- a/chrome/browser/extensions/api/declarative/rules_registry_with_cache.h
+++ b/chrome/browser/extensions/api/declarative/rules_registry_with_cache.h
@@ -10,8 +10,10 @@
#include <map>
#include <string>
+#include <vector>
#include "base/compiler_specific.h"
+#include "base/callback_forward.h"
namespace extensions {
@@ -19,7 +21,33 @@ namespace extensions {
// RulesRegistry::Rule objects.
class RulesRegistryWithCache : public RulesRegistry {
public:
- RulesRegistryWithCache();
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Returns true if the registry is ready and ready to start processing
+ // rules.
+ virtual bool IsReady() = 0;
+
+ // Called to notify the Delegate that the rules for the given extension
+ // have changed.
+ virtual void OnRulesChanged(RulesRegistryWithCache* rules_registry,
+ const std::string& extension_id) = 0;
+ };
+
+ explicit RulesRegistryWithCache(Delegate* delegate);
+
+ // Returns true if we are ready to process rules.
+ bool IsReady() {
+ return !delegate_.get() || delegate_->IsReady();
+ }
+
+ // Add a callback to call when we transition to Ready.
+ void AddReadyCallback(const base::Closure& callback);
+
+ // Called by our delegate when we are ready. This is called exactly once,
+ // if we have a delegate.
+ void OnReady();
// RulesRegistry implementation:
virtual std::string AddRules(
@@ -60,7 +88,14 @@ class RulesRegistryWithCache : public RulesRegistry {
typedef std::pair<ExtensionId, RuleId> RulesDictionaryKey;
typedef std::map<RulesDictionaryKey, linked_ptr<RulesRegistry::Rule> >
RulesDictionary;
+
+ // Notify our delegate that the given extension's rules have changed.
+ void NotifyRulesChanged(const std::string& extension_id);
+
RulesDictionary rules_;
+
+ scoped_ptr<Delegate> delegate_;
+ std::vector<base::Closure> ready_callbacks_;
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698