OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Interface for objects providing content setting rules. | |
6 | |
7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_RULE_H_ | |
8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_RULE_H_ | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/memory/linked_ptr.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/scoped_vector.h" | |
14 #include "base/synchronization/lock.h" | |
15 #include "base/values.h" | |
16 #include "components/content_settings/core/common/content_settings_pattern.h" | |
17 | |
18 namespace content_settings { | |
19 | |
20 struct Rule { | |
21 Rule(); | |
22 // Rule takes ownership of |value|. | |
23 Rule(const ContentSettingsPattern& primary_pattern, | |
24 const ContentSettingsPattern& secondary_pattern, | |
25 base::Value* value); | |
26 ~Rule(); | |
27 | |
28 ContentSettingsPattern primary_pattern; | |
29 ContentSettingsPattern secondary_pattern; | |
30 linked_ptr<base::Value> value; | |
31 }; | |
32 | |
33 class RuleIterator { | |
34 public: | |
35 virtual ~RuleIterator(); | |
36 virtual bool HasNext() const = 0; | |
37 virtual Rule Next() = 0; | |
38 }; | |
39 | |
40 class EmptyRuleIterator : public RuleIterator { | |
41 public: | |
42 virtual ~EmptyRuleIterator(); | |
43 virtual bool HasNext() const OVERRIDE; | |
44 virtual Rule Next() OVERRIDE; | |
45 }; | |
46 | |
47 class ConcatenationIterator : public RuleIterator { | |
48 public: | |
49 // ConcatenationIterator takes ownership of the pointers in the |iterators| | |
50 // list and |auto_lock|. |auto_lock| can be NULL if no locking is needed. | |
51 ConcatenationIterator(ScopedVector<RuleIterator>* iterators, | |
52 base::AutoLock* auto_lock); | |
53 virtual ~ConcatenationIterator(); | |
54 virtual bool HasNext() const OVERRIDE; | |
55 virtual Rule Next() OVERRIDE; | |
56 private: | |
57 ScopedVector<RuleIterator> iterators_; | |
58 scoped_ptr<base::AutoLock> auto_lock_; | |
59 }; | |
60 | |
61 } // namespace content_settings | |
62 | |
63 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_RULE_H_ | |
OLD | NEW |