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.
5 #include "base/logging.h"
6 #include "components/content_settings/core/browser/content_settings_rule.h"
8 namespace content_settings
{
13 const ContentSettingsPattern
& primary_pattern
,
14 const ContentSettingsPattern
& secondary_pattern
,
16 : primary_pattern(primary_pattern
),
17 secondary_pattern(secondary_pattern
),
24 RuleIterator::~RuleIterator() {}
26 EmptyRuleIterator::~EmptyRuleIterator() {}
28 bool EmptyRuleIterator::HasNext() const {
32 Rule
EmptyRuleIterator::Next() {
37 ConcatenationIterator::ConcatenationIterator(
38 ScopedVector
<RuleIterator
>* iterators
,
39 base::AutoLock
* auto_lock
)
40 : auto_lock_(auto_lock
) {
41 iterators_
.swap(*iterators
);
43 ScopedVector
<RuleIterator
>::iterator it
= iterators_
.begin();
44 while (it
!= iterators_
.end()) {
45 if (!(*it
)->HasNext())
46 it
= iterators_
.erase(it
);
52 ConcatenationIterator::~ConcatenationIterator() {}
54 bool ConcatenationIterator::HasNext() const {
55 return (!iterators_
.empty());
58 Rule
ConcatenationIterator::Next() {
59 ScopedVector
<RuleIterator
>::iterator current_iterator
=
61 DCHECK(current_iterator
!= iterators_
.end());
62 DCHECK((*current_iterator
)->HasNext());
63 const Rule
& to_return
= (*current_iterator
)->Next();
64 if (!(*current_iterator
)->HasNext())
65 iterators_
.erase(current_iterator
);
69 } // namespace content_settings