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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 log_storage_init_delay)) | 90 log_storage_init_delay)) |
91 ->GetWeakPtr() | 91 ->GetWeakPtr() |
92 : base::WeakPtr<RuleStorageOnUI>())) { | 92 : base::WeakPtr<RuleStorageOnUI>())) { |
93 if (!profile) { | 93 if (!profile) { |
94 CHECK(!ui_part); | 94 CHECK(!ui_part); |
95 return; | 95 return; |
96 } | 96 } |
97 | 97 |
98 ui_part->reset(storage_on_ui_.get()); | 98 ui_part->reset(storage_on_ui_.get()); |
99 | 99 |
100 // After construction, |this| continues to live only on |owner_thread|. | |
101 weak_ptr_factory_.DetachFromThread(); | |
102 | |
103 storage_on_ui_->Init(); | 100 storage_on_ui_->Init(); |
104 } | 101 } |
105 | 102 |
106 void RulesRegistryWithCache::AddReadyCallback(const base::Closure& callback) { | 103 void RulesRegistryWithCache::AddReadyCallback(const base::Closure& callback) { |
107 ready_callbacks_.push_back(callback); | 104 ready_callbacks_.push_back(callback); |
108 } | 105 } |
109 | 106 |
110 std::string RulesRegistryWithCache::AddRules( | 107 std::string RulesRegistryWithCache::AddRules( |
111 const std::string& extension_id, | 108 const std::string& extension_id, |
112 const std::vector<linked_ptr<Rule> >& rules) { | 109 const std::vector<linked_ptr<Rule> >& rules) { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 base::Passed(&value))); | 395 base::Passed(&value))); |
399 | 396 |
400 waiting_for_extensions_.erase(extension_id); | 397 waiting_for_extensions_.erase(extension_id); |
401 | 398 |
402 if (waiting_for_extensions_.empty()) | 399 if (waiting_for_extensions_.empty()) |
403 ExtensionSystem::Get(profile_)->ready().Post( | 400 ExtensionSystem::Get(profile_)->ready().Post( |
404 FROM_HERE, base::Bind(&RuleStorageOnUI::CheckIfReady, GetWeakPtr())); | 401 FROM_HERE, base::Bind(&RuleStorageOnUI::CheckIfReady, GetWeakPtr())); |
405 } | 402 } |
406 | 403 |
407 } // namespace extensions | 404 } // namespace extensions |
OLD | NEW |