| 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
|
|
|