| 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.h" | 5 #include "chrome/browser/extensions/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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const WebViewKey& webview_key) | 81 const WebViewKey& webview_key) |
| 82 : profile_(profile), | 82 : profile_(profile), |
| 83 owner_thread_(owner_thread), | 83 owner_thread_(owner_thread), |
| 84 event_name_(event_name), | 84 event_name_(event_name), |
| 85 webview_key_(webview_key), | 85 webview_key_(webview_key), |
| 86 weak_ptr_factory_(profile ? this : NULL), | 86 weak_ptr_factory_(profile ? this : NULL), |
| 87 last_generated_rule_identifier_id_(0) { | 87 last_generated_rule_identifier_id_(0) { |
| 88 if (cache_delegate) { | 88 if (cache_delegate) { |
| 89 cache_delegate_ = cache_delegate->GetWeakPtr(); | 89 cache_delegate_ = cache_delegate->GetWeakPtr(); |
| 90 cache_delegate->Init(this); | 90 cache_delegate->Init(this); |
| 91 } else { | |
| 92 content::BrowserThread::PostTask( | |
| 93 owner_thread, | |
| 94 FROM_HERE, | |
| 95 base::Bind(&RulesRegistry::MarkReady, this, base::Time::Now())); | |
| 96 } | 91 } |
| 92 // Note that if |cache_delegate| is NULL, the Rulesregistry never signals its |
| 93 // |ready_| event. That's OK, because that event is only ever needed by the |
| 94 // cache delegate. |
| 97 } | 95 } |
| 98 | 96 |
| 99 std::string RulesRegistry::AddRulesNoFill( | 97 std::string RulesRegistry::AddRulesNoFill( |
| 100 const std::string& extension_id, | 98 const std::string& extension_id, |
| 101 const std::vector<linked_ptr<Rule> >& rules) { | 99 const std::vector<linked_ptr<Rule> >& rules) { |
| 102 DCHECK(content::BrowserThread::CurrentlyOn(owner_thread())); | 100 DCHECK(content::BrowserThread::CurrentlyOn(owner_thread())); |
| 103 | 101 |
| 104 // Verify that all rule IDs are new. | 102 // Verify that all rule IDs are new. |
| 105 for (std::vector<linked_ptr<Rule> >::const_iterator i = | 103 for (std::vector<linked_ptr<Rule> >::const_iterator i = |
| 106 rules.begin(); i != rules.end(); ++i) { | 104 rules.begin(); i != rules.end(); ++i) { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 368 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| 371 used_rule_identifiers_[extension_id].erase(*i); | 369 used_rule_identifiers_[extension_id].erase(*i); |
| 372 } | 370 } |
| 373 | 371 |
| 374 void RulesRegistry::RemoveAllUsedRuleIdentifiers( | 372 void RulesRegistry::RemoveAllUsedRuleIdentifiers( |
| 375 const std::string& extension_id) { | 373 const std::string& extension_id) { |
| 376 used_rule_identifiers_.erase(extension_id); | 374 used_rule_identifiers_.erase(extension_id); |
| 377 } | 375 } |
| 378 | 376 |
| 379 } // namespace extensions | 377 } // namespace extensions |
| OLD | NEW |