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/settings/settings_frontend.h" | 5 #include "chrome/browser/extensions/settings/settings_frontend.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 caches_[settings_namespace::SYNC] = | 110 caches_[settings_namespace::SYNC] = |
111 new SyncOrLocalValueStoreCache( | 111 new SyncOrLocalValueStoreCache( |
112 settings_namespace::SYNC, | 112 settings_namespace::SYNC, |
113 factory, | 113 factory, |
114 sync_quota_limit_, | 114 sync_quota_limit_, |
115 observers_, | 115 observers_, |
116 profile_path); | 116 profile_path); |
117 | 117 |
118 #if defined(ENABLE_CONFIGURATION_POLICY) | 118 #if defined(ENABLE_CONFIGURATION_POLICY) |
119 caches_[settings_namespace::MANAGED] = | 119 caches_[settings_namespace::MANAGED] = |
120 new ManagedValueStoreCache(profile->GetPolicyService()); | 120 new ManagedValueStoreCache(profile->GetPolicyService(), observers_); |
121 #endif | 121 #endif |
122 } | 122 } |
123 | 123 |
124 SettingsFrontend::~SettingsFrontend() { | 124 SettingsFrontend::~SettingsFrontend() { |
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
126 observers_->RemoveObserver(profile_observer_.get()); | 126 observers_->RemoveObserver(profile_observer_.get()); |
127 // Destroy each cache in its preferred thread. The delete task will execute | 127 // Destroy each cache in its preferred thread. The delete task will execute |
128 // after any other task that might've been posted before. | 128 // after any other task that might've been posted before. |
129 for (CacheMap::iterator it = caches_.begin(); it != caches_.end(); ++it) { | 129 for (CacheMap::iterator it = caches_.begin(); it != caches_.end(); ++it) { |
130 ValueStoreCache* cache = it->second; | 130 ValueStoreCache* cache = it->second; |
| 131 cache->ShutdownOnUI(); |
131 cache->GetMessageLoop()->DeleteSoon(FROM_HERE, cache); | 132 cache->GetMessageLoop()->DeleteSoon(FROM_HERE, cache); |
132 } | 133 } |
133 } | 134 } |
134 | 135 |
135 syncer::SyncableService* SettingsFrontend::GetBackendForSync( | 136 syncer::SyncableService* SettingsFrontend::GetBackendForSync( |
136 syncer::ModelType type) const { | 137 syncer::ModelType type) const { |
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
138 CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC); | 139 CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC); |
139 DCHECK(it != caches_.end()); | 140 DCHECK(it != caches_.end()); |
140 const SyncOrLocalValueStoreCache* sync_cache = | 141 const SyncOrLocalValueStoreCache* sync_cache = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 scoped_refptr<SettingsObserverList> SettingsFrontend::GetObservers() { | 195 scoped_refptr<SettingsObserverList> SettingsFrontend::GetObservers() { |
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
196 return observers_; | 197 return observers_; |
197 } | 198 } |
198 | 199 |
199 void SettingsFrontend::DisableStorageForTesting( | 200 void SettingsFrontend::DisableStorageForTesting( |
200 settings_namespace::Namespace settings_namespace) { | 201 settings_namespace::Namespace settings_namespace) { |
201 CacheMap::iterator it = caches_.find(settings_namespace); | 202 CacheMap::iterator it = caches_.find(settings_namespace); |
202 if (it != caches_.end()) { | 203 if (it != caches_.end()) { |
203 ValueStoreCache* cache = it->second; | 204 ValueStoreCache* cache = it->second; |
| 205 cache->ShutdownOnUI(); |
204 cache->GetMessageLoop()->DeleteSoon(FROM_HERE, cache); | 206 cache->GetMessageLoop()->DeleteSoon(FROM_HERE, cache); |
205 caches_.erase(it); | 207 caches_.erase(it); |
206 } | 208 } |
207 } | 209 } |
208 | 210 |
209 } // namespace extensions | 211 } // namespace extensions |
OLD | NEW |