OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__ |
7 | 7 |
8 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | 8 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 18 matching lines...) Expand all Loading... |
29 virtual bool IsReady() = 0; | 29 virtual bool IsReady() = 0; |
30 | 30 |
31 // Called to notify the Delegate that the rules for the given extension | 31 // Called to notify the Delegate that the rules for the given extension |
32 // have changed. | 32 // have changed. |
33 virtual void OnRulesChanged(RulesRegistryWithCache* rules_registry, | 33 virtual void OnRulesChanged(RulesRegistryWithCache* rules_registry, |
34 const std::string& extension_id) = 0; | 34 const std::string& extension_id) = 0; |
35 }; | 35 }; |
36 | 36 |
37 explicit RulesRegistryWithCache(Delegate* delegate); | 37 explicit RulesRegistryWithCache(Delegate* delegate); |
38 | 38 |
39 // Returns true if we are ready to process rules. | |
40 bool IsReady() { | |
41 return !delegate_.get() || delegate_->IsReady(); | |
42 } | |
43 | |
44 // Add a callback to call when we transition to Ready. | |
45 void AddReadyCallback(const base::Closure& callback); | |
46 | |
47 // Called by our delegate when we are ready. This is called exactly once, | 39 // Called by our delegate when we are ready. This is called exactly once, |
48 // if we have a delegate. | 40 // if we have a delegate. |
49 void OnReady(); | 41 void OnReady(); |
50 | 42 |
51 // RulesRegistry implementation: | 43 // RulesRegistry implementation: |
52 virtual std::string AddRules( | 44 virtual std::string AddRules( |
53 const std::string& extension_id, | 45 const std::string& extension_id, |
54 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; | 46 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; |
55 virtual std::string RemoveRules( | 47 virtual std::string RemoveRules( |
56 const std::string& extension_id, | 48 const std::string& extension_id, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 85 |
94 RulesDictionary rules_; | 86 RulesDictionary rules_; |
95 | 87 |
96 scoped_ptr<Delegate> delegate_; | 88 scoped_ptr<Delegate> delegate_; |
97 std::vector<base::Closure> ready_callbacks_; | 89 std::vector<base::Closure> ready_callbacks_; |
98 }; | 90 }; |
99 | 91 |
100 } // namespace extensions | 92 } // namespace extensions |
101 | 93 |
102 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H
__ | 94 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H
__ |
OLD | NEW |