OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/preferences/public/cpp/pref_store_client_mixin.h" | 5 #include "services/preferences/public/cpp/pref_store_client_mixin.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "services/preferences/public/cpp/pref_store_client.h" | 10 #include "services/preferences/public/cpp/pref_store_client.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (cached_prefs_->Get(key, &prev)) { | 95 if (cached_prefs_->Get(key, &prev)) { |
96 if (!prev->Equals(value.get())) { | 96 if (!prev->Equals(value.get())) { |
97 cached_prefs_->Set(key, std::move(value)); | 97 cached_prefs_->Set(key, std::move(value)); |
98 changed = true; | 98 changed = true; |
99 } | 99 } |
100 } else { | 100 } else { |
101 cached_prefs_->Set(key, std::move(value)); | 101 cached_prefs_->Set(key, std::move(value)); |
102 changed = true; | 102 changed = true; |
103 } | 103 } |
104 } | 104 } |
105 if (changed) | 105 if (changed && initialized_) |
106 ReportPrefValueChanged(key); | 106 ReportPrefValueChanged(key); |
107 } | 107 } |
108 | 108 |
109 template <typename BasePrefStore> | 109 template <typename BasePrefStore> |
110 void PrefStoreClientMixin<BasePrefStore>::OnInitializationCompleted( | 110 void PrefStoreClientMixin<BasePrefStore>::OnInitializationCompleted( |
111 bool succeeded) { | 111 bool succeeded) { |
112 if (!initialized_) { | 112 if (!initialized_) { |
113 initialized_ = true; | 113 initialized_ = true; |
114 for (auto& observer : observers_) | 114 for (auto& observer : observers_) |
115 observer.OnInitializationCompleted(succeeded); | 115 observer.OnInitializationCompleted(succeeded); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 template class PrefStoreClientMixin<::PrefStore>; | 119 template class PrefStoreClientMixin<::PrefStore>; |
120 template class PrefStoreClientMixin<::PersistentPrefStore>; | 120 template class PrefStoreClientMixin<::PersistentPrefStore>; |
121 | 121 |
122 } // namespace prefs | 122 } // namespace prefs |
OLD | NEW |