| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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.h" | 5 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 | 69 |
| 70 namespace extensions { | 70 namespace extensions { |
| 71 | 71 |
| 72 // RulesRegistry | 72 // RulesRegistry |
| 73 | 73 |
| 74 RulesRegistry::RulesRegistry( | 74 RulesRegistry::RulesRegistry( |
| 75 Profile* profile, | 75 Profile* profile, |
| 76 const std::string& event_name, | 76 const std::string& event_name, |
| 77 content::BrowserThread::ID owner_thread, | 77 content::BrowserThread::ID owner_thread, |
| 78 RulesCacheDelegate* cache_delegate) | 78 RulesCacheDelegate* cache_delegate, |
| 79 const WebViewKey& webview_key) |
| 79 : profile_(profile), | 80 : profile_(profile), |
| 80 owner_thread_(owner_thread), | 81 owner_thread_(owner_thread), |
| 81 event_name_(event_name), | 82 event_name_(event_name), |
| 83 webview_key_(webview_key), |
| 82 weak_ptr_factory_(profile ? this : NULL), | 84 weak_ptr_factory_(profile ? this : NULL), |
| 83 process_changed_rules_requested_(profile ? NOT_SCHEDULED_FOR_PROCESSING | 85 process_changed_rules_requested_(profile ? NOT_SCHEDULED_FOR_PROCESSING |
| 84 : NEVER_PROCESS), | 86 : NEVER_PROCESS), |
| 85 last_generated_rule_identifier_id_(0) { | 87 last_generated_rule_identifier_id_(0) { |
| 86 if (cache_delegate) { | 88 if (cache_delegate) { |
| 87 cache_delegate_ = cache_delegate->GetWeakPtr(); | 89 cache_delegate_ = cache_delegate->GetWeakPtr(); |
| 88 cache_delegate->Init(this); | 90 cache_delegate->Init(this); |
| 89 } else { | 91 } else { |
| 90 ready_.Signal(); | 92 content::BrowserThread::PostTask( |
| 93 owner_thread, |
| 94 FROM_HERE, |
| 95 base::Bind(&RulesRegistry::MarkReady, this, base::Time::Now())); |
| 91 } | 96 } |
| 92 } | 97 } |
| 93 | 98 |
| 94 std::string RulesRegistry::AddRules( | 99 std::string RulesRegistry::AddRules( |
| 95 const std::string& extension_id, | 100 const std::string& extension_id, |
| 96 const std::vector<linked_ptr<Rule> >& rules) { | 101 const std::vector<linked_ptr<Rule> >& rules) { |
| 97 DCHECK(content::BrowserThread::CurrentlyOn(owner_thread())); | 102 DCHECK(content::BrowserThread::CurrentlyOn(owner_thread())); |
| 98 | 103 |
| 99 std::string error = CheckAndFillInOptionalRules(extension_id, rules); | 104 std::string error = CheckAndFillInOptionalRules(extension_id, rules); |
| 100 if (!error.empty()) | 105 if (!error.empty()) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 341 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| 337 used_rule_identifiers_[extension_id].erase(*i); | 342 used_rule_identifiers_[extension_id].erase(*i); |
| 338 } | 343 } |
| 339 | 344 |
| 340 void RulesRegistry::RemoveAllUsedRuleIdentifiers( | 345 void RulesRegistry::RemoveAllUsedRuleIdentifiers( |
| 341 const std::string& extension_id) { | 346 const std::string& extension_id) { |
| 342 used_rule_identifiers_.erase(extension_id); | 347 used_rule_identifiers_.erase(extension_id); |
| 343 } | 348 } |
| 344 | 349 |
| 345 } // namespace extensions | 350 } // namespace extensions |
| OLD | NEW |