| 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 |
| 23 void RulesRegistryWithCache::OnReady() { | 27 void RulesRegistryWithCache::OnReady() { |
| 24 for (size_t i = 0; i < ready_callbacks_.size(); ++i) | 28 for (size_t i = 0; i < ready_callbacks_.size(); ++i) |
| 25 ready_callbacks_[i].Run(); | 29 ready_callbacks_[i].Run(); |
| 26 ready_callbacks_.clear(); | 30 ready_callbacks_.clear(); |
| 27 } | 31 } |
| 28 | 32 |
| 29 std::string RulesRegistryWithCache::AddRules( | 33 std::string RulesRegistryWithCache::AddRules( |
| 30 const std::string& extension_id, | 34 const std::string& extension_id, |
| 31 const std::vector<linked_ptr<Rule> >& rules) { | 35 const std::vector<linked_ptr<Rule> >& rules) { |
| 32 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); | 36 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const std::string& extension_id) { | 146 const std::string& extension_id) { |
| 143 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); | 147 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); |
| 144 | 148 |
| 145 if (delegate_.get()) | 149 if (delegate_.get()) |
| 146 delegate_->OnRulesChanged(this, extension_id); | 150 delegate_->OnRulesChanged(this, extension_id); |
| 147 } | 151 } |
| 148 | 152 |
| 149 RulesRegistryWithCache::~RulesRegistryWithCache() {} | 153 RulesRegistryWithCache::~RulesRegistryWithCache() {} |
| 150 | 154 |
| 151 } // namespace extensions | 155 } // namespace extensions |
| OLD | NEW |