OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/prefs/pref_value_store.h" | 5 #include "chrome/browser/prefs/pref_value_store.h" |
6 | 6 |
7 #include "chrome/browser/prefs/pref_notifier.h" | 7 #include "chrome/browser/prefs/pref_notifier.h" |
8 | 8 |
9 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper() | 9 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper() |
10 : pref_value_store_(NULL), | 10 : pref_value_store_(NULL), |
(...skipping 19 matching lines...) Expand all Loading... |
30 pref_store_ = pref_store; | 30 pref_store_ = pref_store; |
31 if (pref_store_.get()) | 31 if (pref_store_.get()) |
32 pref_store_->AddObserver(this); | 32 pref_store_->AddObserver(this); |
33 } | 33 } |
34 | 34 |
35 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged( | 35 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged( |
36 const std::string& key) { | 36 const std::string& key) { |
37 pref_value_store_->OnPrefValueChanged(type_, key); | 37 pref_value_store_->OnPrefValueChanged(type_, key); |
38 } | 38 } |
39 | 39 |
40 void PrefValueStore::PrefStoreKeeper::OnInitializationCompleted() { | 40 void PrefValueStore::PrefStoreKeeper::OnInitializationCompleted( |
41 pref_value_store_->OnInitializationCompleted(type_); | 41 bool succeeded) { |
| 42 pref_value_store_->OnInitializationCompleted(type_, succeeded); |
42 } | 43 } |
43 | 44 |
44 PrefValueStore::PrefValueStore(PrefStore* managed_platform_prefs, | 45 PrefValueStore::PrefValueStore(PrefStore* managed_platform_prefs, |
45 PrefStore* managed_cloud_prefs, | 46 PrefStore* managed_cloud_prefs, |
46 PrefStore* extension_prefs, | 47 PrefStore* extension_prefs, |
47 PrefStore* command_line_prefs, | 48 PrefStore* command_line_prefs, |
48 PrefStore* user_prefs, | 49 PrefStore* user_prefs, |
49 PrefStore* recommended_platform_prefs, | 50 PrefStore* recommended_platform_prefs, |
50 PrefStore* recommended_cloud_prefs, | 51 PrefStore* recommended_cloud_prefs, |
51 PrefStore* default_prefs, | 52 PrefStore* default_prefs, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 *out_value = NULL; | 232 *out_value = NULL; |
232 return false; | 233 return false; |
233 } | 234 } |
234 | 235 |
235 void PrefValueStore::OnPrefValueChanged(PrefValueStore::PrefStoreType type, | 236 void PrefValueStore::OnPrefValueChanged(PrefValueStore::PrefStoreType type, |
236 const std::string& key) { | 237 const std::string& key) { |
237 NotifyPrefChanged(key.c_str(), type); | 238 NotifyPrefChanged(key.c_str(), type); |
238 } | 239 } |
239 | 240 |
240 void PrefValueStore::OnInitializationCompleted( | 241 void PrefValueStore::OnInitializationCompleted( |
241 PrefValueStore::PrefStoreType type) { | 242 PrefValueStore::PrefStoreType type, bool succeeded) { |
| 243 if (!succeeded) { |
| 244 pref_notifier_->OnInitializationCompleted(false); |
| 245 return; |
| 246 } |
242 CheckInitializationCompleted(); | 247 CheckInitializationCompleted(); |
243 } | 248 } |
244 | 249 |
245 void PrefValueStore::InitPrefStore(PrefValueStore::PrefStoreType type, | 250 void PrefValueStore::InitPrefStore(PrefValueStore::PrefStoreType type, |
246 PrefStore* pref_store) { | 251 PrefStore* pref_store) { |
247 pref_stores_[type].Initialize(this, pref_store, type); | 252 pref_stores_[type].Initialize(this, pref_store, type); |
248 } | 253 } |
249 | 254 |
250 void PrefValueStore::CheckInitializationCompleted() { | 255 void PrefValueStore::CheckInitializationCompleted() { |
251 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { | 256 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { |
252 scoped_refptr<PrefStore> store = | 257 scoped_refptr<PrefStore> store = |
253 GetPrefStore(static_cast<PrefStoreType>(i)); | 258 GetPrefStore(static_cast<PrefStoreType>(i)); |
254 if (store && !store->IsInitializationComplete()) | 259 if (store && !store->IsInitializationComplete()) |
255 return; | 260 return; |
256 } | 261 } |
257 pref_notifier_->OnInitializationCompleted(); | 262 pref_notifier_->OnInitializationCompleted(true); |
258 } | 263 } |
OLD | NEW |