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 #include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h" | 5 #include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 const char kSuccess[] = ""; | 12 const char kSuccess[] = ""; |
13 const char kDuplicateRuleId[] = "Duplicate rule ID: %s"; | 13 const char kDuplicateRuleId[] = "Duplicate rule ID: %s"; |
14 | 14 |
15 } // namespace | 15 } // namespace |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 RulesRegistryWithCache::RulesRegistryWithCache(Delegate* delegate) | 19 RulesRegistryWithCache::RulesRegistryWithCache(Delegate* delegate) |
20 : delegate_(delegate) { | 20 : delegate_(delegate) { |
21 } | 21 } |
22 | 22 |
23 void RulesRegistryWithCache::AddReadyCallback(const base::Closure& callback) { | |
24 ready_callbacks_.push_back(callback); | |
25 } | |
26 | |
27 void RulesRegistryWithCache::OnReady() { | 23 void RulesRegistryWithCache::OnReady() { |
28 for (size_t i = 0; i < ready_callbacks_.size(); ++i) | 24 for (size_t i = 0; i < ready_callbacks_.size(); ++i) |
29 ready_callbacks_[i].Run(); | 25 ready_callbacks_[i].Run(); |
30 ready_callbacks_.clear(); | 26 ready_callbacks_.clear(); |
battre
2012/12/01 02:27:54
I think this is now broken. You cannot add read_ca
Matt Perry
2012/12/03 17:56:19
I should've looked at this more closely. There's a
| |
31 } | 27 } |
32 | 28 |
33 std::string RulesRegistryWithCache::AddRules( | 29 std::string RulesRegistryWithCache::AddRules( |
34 const std::string& extension_id, | 30 const std::string& extension_id, |
35 const std::vector<linked_ptr<Rule> >& rules) { | 31 const std::vector<linked_ptr<Rule> >& rules) { |
36 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); | 32 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); |
37 | 33 |
38 // Verify that all rule IDs are new. | 34 // Verify that all rule IDs are new. |
39 for (std::vector<linked_ptr<Rule> >::const_iterator i = | 35 for (std::vector<linked_ptr<Rule> >::const_iterator i = |
40 rules.begin(); i != rules.end(); ++i) { | 36 rules.begin(); i != rules.end(); ++i) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 const std::string& extension_id) { | 142 const std::string& extension_id) { |
147 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); | 143 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); |
148 | 144 |
149 if (delegate_.get()) | 145 if (delegate_.get()) |
150 delegate_->OnRulesChanged(this, extension_id); | 146 delegate_->OnRulesChanged(this, extension_id); |
151 } | 147 } |
152 | 148 |
153 RulesRegistryWithCache::~RulesRegistryWithCache() {} | 149 RulesRegistryWithCache::~RulesRegistryWithCache() {} |
154 | 150 |
155 } // namespace extensions | 151 } // namespace extensions |
OLD | NEW |