| 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() {} | 19 RulesRegistryWithCache::RulesRegistryWithCache() {} |
| 20 | 20 |
| 21 RulesRegistryWithCache::~RulesRegistryWithCache() {} | |
| 22 | |
| 23 std::string RulesRegistryWithCache::AddRules( | 21 std::string RulesRegistryWithCache::AddRules( |
| 24 const std::string& extension_id, | 22 const std::string& extension_id, |
| 25 const std::vector<linked_ptr<Rule> >& rules) { | 23 const std::vector<linked_ptr<Rule> >& rules) { |
| 26 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); | 24 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); |
| 27 | 25 |
| 28 // Verify that all rule IDs are new. | 26 // Verify that all rule IDs are new. |
| 29 for (std::vector<linked_ptr<Rule> >::const_iterator i = | 27 for (std::vector<linked_ptr<Rule> >::const_iterator i = |
| 30 rules.begin(); i != rules.end(); ++i) { | 28 rules.begin(); i != rules.end(); ++i) { |
| 31 const RuleId& rule_id = *((*i)->id); | 29 const RuleId& rule_id = *((*i)->id); |
| 32 RulesDictionaryKey key(extension_id, rule_id); | 30 RulesDictionaryKey key(extension_id, rule_id); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 117 } |
| 120 | 118 |
| 121 void RulesRegistryWithCache::OnExtensionUnloaded( | 119 void RulesRegistryWithCache::OnExtensionUnloaded( |
| 122 const std::string& extension_id) { | 120 const std::string& extension_id) { |
| 123 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); | 121 DCHECK(content::BrowserThread::CurrentlyOn(GetOwnerThread())); |
| 124 std::string error = RemoveAllRules(extension_id); | 122 std::string error = RemoveAllRules(extension_id); |
| 125 if (!error.empty()) | 123 if (!error.empty()) |
| 126 LOG(ERROR) << error; | 124 LOG(ERROR) << error; |
| 127 } | 125 } |
| 128 | 126 |
| 127 RulesRegistryWithCache::~RulesRegistryWithCache() {} |
| 128 |
| 129 } // namespace extensions | 129 } // namespace extensions |
| OLD | NEW |