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 |
39 // Called by our delegate when we are ready. This is called exactly once, | 47 // Called by our delegate when we are ready. This is called exactly once, |
40 // if we have a delegate. | 48 // if we have a delegate. |
41 void OnReady(); | 49 void OnReady(); |
42 | 50 |
43 // RulesRegistry implementation: | 51 // RulesRegistry implementation: |
44 virtual std::string AddRules( | 52 virtual std::string AddRules( |
45 const std::string& extension_id, | 53 const std::string& extension_id, |
46 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; | 54 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; |
47 virtual std::string RemoveRules( | 55 virtual std::string RemoveRules( |
48 const std::string& extension_id, | 56 const std::string& extension_id, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 93 |
86 RulesDictionary rules_; | 94 RulesDictionary rules_; |
87 | 95 |
88 scoped_ptr<Delegate> delegate_; | 96 scoped_ptr<Delegate> delegate_; |
89 std::vector<base::Closure> ready_callbacks_; | 97 std::vector<base::Closure> ready_callbacks_; |
90 }; | 98 }; |
91 | 99 |
92 } // namespace extensions | 100 } // namespace extensions |
93 | 101 |
94 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H
__ | 102 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H
__ |
OLD | NEW |