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_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "chrome/common/extensions/api/declarative.h" | 14 #include "chrome/common/extensions/api/events.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 } | 19 } |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 class RulesRegistry; | 23 class RulesRegistry; |
24 | 24 |
25 // Traits that describe how RulesRegistry should be deleted. This just deletes | 25 // Traits that describe how RulesRegistry should be deleted. This just deletes |
26 // the RulesRegistry on its owner thread. | 26 // the RulesRegistry on its owner thread. |
27 struct RulesRegistryDeleteTraits { | 27 struct RulesRegistryDeleteTraits { |
28 public: | 28 public: |
29 static void Destruct(const RulesRegistry* rules_registry); | 29 static void Destruct(const RulesRegistry* rules_registry); |
30 }; | 30 }; |
31 | 31 |
32 // Interface for rule registries. | 32 // Interface for rule registries. |
33 // | 33 // |
34 // All functions except GetOwnerThread() are only called on the thread | 34 // All functions except GetOwnerThread() are only called on the thread |
35 // indicated by GetOwnerThread(). The object is destroyed on the owner thread. | 35 // indicated by GetOwnerThread(). The object is destroyed on the owner thread. |
36 class RulesRegistry | 36 class RulesRegistry |
37 : public base::RefCountedThreadSafe<RulesRegistry, | 37 : public base::RefCountedThreadSafe<RulesRegistry, |
38 RulesRegistryDeleteTraits> { | 38 RulesRegistryDeleteTraits> { |
39 public: | 39 public: |
40 typedef extensions::api::declarative::Rule Rule; | 40 typedef extensions::api::events::Rule Rule; |
41 | 41 |
42 // Registers |rules|, owned by |extension_id| to this RulesRegistry. | 42 // Registers |rules|, owned by |extension_id| to this RulesRegistry. |
43 // If a concrete RuleRegistry does not support some of the rules, | 43 // If a concrete RuleRegistry does not support some of the rules, |
44 // it may ignore them. | 44 // it may ignore them. |
45 // | 45 // |
46 // |rules| is a list of Rule instances following the definition of the | 46 // |rules| is a list of Rule instances following the definition of the |
47 // declarative extension APIs. It is guaranteed that each rule in |rules| has | 47 // declarative extension APIs. It is guaranteed that each rule in |rules| has |
48 // a unique name within the scope of |extension_id| that has not been | 48 // a unique name within the scope of |extension_id| that has not been |
49 // registered before, unless it has been removed again. | 49 // registered before, unless it has been removed again. |
50 // The ownership of rules remains with the caller. | 50 // The ownership of rules remains with the caller. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 protected: | 102 protected: |
103 friend struct RulesRegistryDeleteTraits; | 103 friend struct RulesRegistryDeleteTraits; |
104 friend class base::DeleteHelper<RulesRegistry>; | 104 friend class base::DeleteHelper<RulesRegistry>; |
105 virtual ~RulesRegistry() {} | 105 virtual ~RulesRegistry() {} |
106 }; | 106 }; |
107 | 107 |
108 } // namespace extensions | 108 } // namespace extensions |
109 | 109 |
110 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ | 110 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
OLD | NEW |