| 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 "extensions/browser/api/declarative/rules_registry.h" | 5 #include "extensions/browser/api/declarative/rules_registry.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 | 67 |
| 68 namespace extensions { | 68 namespace extensions { |
| 69 | 69 |
| 70 // RulesRegistry | 70 // RulesRegistry |
| 71 | 71 |
| 72 RulesRegistry::RulesRegistry(content::BrowserContext* browser_context, | 72 RulesRegistry::RulesRegistry(content::BrowserContext* browser_context, |
| 73 const std::string& event_name, | 73 const std::string& event_name, |
| 74 content::BrowserThread::ID owner_thread, | 74 content::BrowserThread::ID owner_thread, |
| 75 RulesCacheDelegate* cache_delegate, | 75 RulesCacheDelegate* cache_delegate, |
| 76 const WebViewKey& webview_key) | 76 int id) |
| 77 : browser_context_(browser_context), | 77 : browser_context_(browser_context), |
| 78 owner_thread_(owner_thread), | 78 owner_thread_(owner_thread), |
| 79 event_name_(event_name), | 79 event_name_(event_name), |
| 80 webview_key_(webview_key), | 80 id_(id), |
| 81 ready_(/*signaled=*/!cache_delegate), // Immediately ready if no cache | 81 ready_(/*signaled=*/!cache_delegate), // Immediately ready if no cache |
| 82 // delegate to wait for. | 82 // delegate to wait for. |
| 83 last_generated_rule_identifier_id_(0), | 83 last_generated_rule_identifier_id_(0), |
| 84 weak_ptr_factory_(browser_context_ ? this : NULL) { | 84 weak_ptr_factory_(browser_context_ ? this : NULL) { |
| 85 if (cache_delegate) { | 85 if (cache_delegate) { |
| 86 cache_delegate_ = cache_delegate->GetWeakPtr(); | 86 cache_delegate_ = cache_delegate->GetWeakPtr(); |
| 87 cache_delegate->Init(this); | 87 cache_delegate->Init(this); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 RulesDictionaryKey lookup_key(extension_id, *i); | 193 RulesDictionaryKey lookup_key(extension_id, *i); |
| 194 RulesDictionary::iterator entry = rules_.find(lookup_key); | 194 RulesDictionary::iterator entry = rules_.find(lookup_key); |
| 195 if (entry != rules_.end()) | 195 if (entry != rules_.end()) |
| 196 out->push_back(entry->second); | 196 out->push_back(entry->second); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 void RulesRegistry::GetAllRules(const std::string& extension_id, | 200 void RulesRegistry::GetAllRules(const std::string& extension_id, |
| 201 std::vector<linked_ptr<Rule> >* out) { | 201 std::vector<linked_ptr<Rule> >* out) { |
| 202 DCHECK_CURRENTLY_ON(owner_thread()); | 202 DCHECK_CURRENTLY_ON(owner_thread()); |
| 203 | |
| 204 for (RulesDictionary::const_iterator i = rules_.begin(); | 203 for (RulesDictionary::const_iterator i = rules_.begin(); |
| 205 i != rules_.end(); ++i) { | 204 i != rules_.end(); ++i) { |
| 206 const RulesDictionaryKey& key = i->first; | 205 const RulesDictionaryKey& key = i->first; |
| 207 if (key.first == extension_id) | 206 if (key.first == extension_id) |
| 208 out->push_back(i->second); | 207 out->push_back(i->second); |
| 209 } | 208 } |
| 210 } | 209 } |
| 211 | 210 |
| 212 void RulesRegistry::OnExtensionUnloaded(const std::string& extension_id) { | 211 void RulesRegistry::OnExtensionUnloaded(const std::string& extension_id) { |
| 213 DCHECK_CURRENTLY_ON(owner_thread()); | 212 DCHECK_CURRENTLY_ON(owner_thread()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 367 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| 369 used_rule_identifiers_[extension_id].erase(*i); | 368 used_rule_identifiers_[extension_id].erase(*i); |
| 370 } | 369 } |
| 371 | 370 |
| 372 void RulesRegistry::RemoveAllUsedRuleIdentifiers( | 371 void RulesRegistry::RemoveAllUsedRuleIdentifiers( |
| 373 const std::string& extension_id) { | 372 const std::string& extension_id) { |
| 374 used_rule_identifiers_.erase(extension_id); | 373 used_rule_identifiers_.erase(extension_id); |
| 375 } | 374 } |
| 376 | 375 |
| 377 } // namespace extensions | 376 } // namespace extensions |
| OLD | NEW |