| 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/value_map_pref_store.h" | 5 #include "components/prefs/value_map_pref_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 observers_.RemoveObserver(observer); | 25 observers_.RemoveObserver(observer); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool ValueMapPrefStore::HasObservers() const { | 28 bool ValueMapPrefStore::HasObservers() const { |
| 29 return observers_.might_have_observers(); | 29 return observers_.might_have_observers(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void ValueMapPrefStore::SetValue(const std::string& key, | 32 void ValueMapPrefStore::SetValue(const std::string& key, |
| 33 std::unique_ptr<base::Value> value, | 33 std::unique_ptr<base::Value> value, |
| 34 uint32_t flags) { | 34 uint32_t flags) { |
| 35 if (prefs_.SetValue(key, std::move(value))) | 35 if (prefs_.SetValue(key, std::move(value))) { |
| 36 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 36 for (Observer& observer : observers_) |
| 37 observer.OnPrefValueChanged(key); |
| 38 } |
| 37 } | 39 } |
| 38 | 40 |
| 39 void ValueMapPrefStore::RemoveValue(const std::string& key, uint32_t flags) { | 41 void ValueMapPrefStore::RemoveValue(const std::string& key, uint32_t flags) { |
| 40 if (prefs_.RemoveValue(key)) | 42 if (prefs_.RemoveValue(key)) { |
| 41 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 43 for (Observer& observer : observers_) |
| 44 observer.OnPrefValueChanged(key); |
| 45 } |
| 42 } | 46 } |
| 43 | 47 |
| 44 bool ValueMapPrefStore::GetMutableValue(const std::string& key, | 48 bool ValueMapPrefStore::GetMutableValue(const std::string& key, |
| 45 base::Value** value) { | 49 base::Value** value) { |
| 46 return prefs_.GetValue(key, value); | 50 return prefs_.GetValue(key, value); |
| 47 } | 51 } |
| 48 | 52 |
| 49 void ValueMapPrefStore::ReportValueChanged(const std::string& key, | 53 void ValueMapPrefStore::ReportValueChanged(const std::string& key, |
| 50 uint32_t flags) { | 54 uint32_t flags) { |
| 51 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 55 for (Observer& observer : observers_) |
| 56 observer.OnPrefValueChanged(key); |
| 52 } | 57 } |
| 53 | 58 |
| 54 void ValueMapPrefStore::SetValueSilently(const std::string& key, | 59 void ValueMapPrefStore::SetValueSilently(const std::string& key, |
| 55 std::unique_ptr<base::Value> value, | 60 std::unique_ptr<base::Value> value, |
| 56 uint32_t flags) { | 61 uint32_t flags) { |
| 57 prefs_.SetValue(key, std::move(value)); | 62 prefs_.SetValue(key, std::move(value)); |
| 58 } | 63 } |
| 59 | 64 |
| 60 ValueMapPrefStore::~ValueMapPrefStore() {} | 65 ValueMapPrefStore::~ValueMapPrefStore() {} |
| 61 | 66 |
| 62 void ValueMapPrefStore::NotifyInitializationCompleted() { | 67 void ValueMapPrefStore::NotifyInitializationCompleted() { |
| 63 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); | 68 for (Observer& observer : observers_) |
| 69 observer.OnInitializationCompleted(true); |
| 64 } | 70 } |
| OLD | NEW |