| 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 "components/prefs/overlay_user_pref_store.h" | 5 #include "components/prefs/overlay_user_pref_store.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 underlay_->CommitPendingWrite(); | 123 underlay_->CommitPendingWrite(); |
| 124 // We do not write our content intentionally. | 124 // We do not write our content intentionally. |
| 125 } | 125 } |
| 126 | 126 |
| 127 void OverlayUserPrefStore::SchedulePendingLossyWrites() { | 127 void OverlayUserPrefStore::SchedulePendingLossyWrites() { |
| 128 underlay_->SchedulePendingLossyWrites(); | 128 underlay_->SchedulePendingLossyWrites(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void OverlayUserPrefStore::ReportValueChanged(const std::string& key, | 131 void OverlayUserPrefStore::ReportValueChanged(const std::string& key, |
| 132 uint32_t flags) { | 132 uint32_t flags) { |
| 133 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 133 for (PrefStore::Observer& observer : observers_) |
| 134 observer.OnPrefValueChanged(key); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) { | 137 void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) { |
| 137 if (!overlay_.GetValue(GetOverlayKey(key), NULL)) | 138 if (!overlay_.GetValue(GetOverlayKey(key), NULL)) |
| 138 ReportValueChanged(GetOverlayKey(key), DEFAULT_PREF_WRITE_FLAGS); | 139 ReportValueChanged(GetOverlayKey(key), DEFAULT_PREF_WRITE_FLAGS); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) { | 142 void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) { |
| 142 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 143 for (PrefStore::Observer& observer : observers_) |
| 143 OnInitializationCompleted(succeeded)); | 144 observer.OnInitializationCompleted(succeeded); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void OverlayUserPrefStore::RegisterOverlayPref(const std::string& key) { | 147 void OverlayUserPrefStore::RegisterOverlayPref(const std::string& key) { |
| 147 RegisterOverlayPref(key, key); | 148 RegisterOverlayPref(key, key); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void OverlayUserPrefStore::RegisterOverlayPref( | 151 void OverlayUserPrefStore::RegisterOverlayPref( |
| 151 const std::string& overlay_key, | 152 const std::string& overlay_key, |
| 152 const std::string& underlay_key) { | 153 const std::string& underlay_key) { |
| 153 DCHECK(!overlay_key.empty()) << "Overlay key is empty"; | 154 DCHECK(!overlay_key.empty()) << "Overlay key is empty"; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 182 NamesMap::const_iterator i = | 183 NamesMap::const_iterator i = |
| 183 overlay_to_underlay_names_map_.find(overlay_key); | 184 overlay_to_underlay_names_map_.find(overlay_key); |
| 184 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key; | 185 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key; |
| 185 } | 186 } |
| 186 | 187 |
| 187 bool OverlayUserPrefStore::ShallBeStoredInOverlay( | 188 bool OverlayUserPrefStore::ShallBeStoredInOverlay( |
| 188 const std::string& key) const { | 189 const std::string& key) const { |
| 189 return overlay_to_underlay_names_map_.find(key) != | 190 return overlay_to_underlay_names_map_.find(key) != |
| 190 overlay_to_underlay_names_map_.end(); | 191 overlay_to_underlay_names_map_.end(); |
| 191 } | 192 } |
| OLD | NEW |