| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/value_map_pref_store.h" | 5 #include "chrome/browser/prefs/value_map_pref_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 | 11 |
| 12 ValueMapPrefStore::ValueMapPrefStore() {} |
| 13 |
| 14 ValueMapPrefStore::~ValueMapPrefStore() {} |
| 15 |
| 12 PrefStore::ReadResult ValueMapPrefStore::GetValue(const std::string& key, | 16 PrefStore::ReadResult ValueMapPrefStore::GetValue(const std::string& key, |
| 13 Value** value) const { | 17 Value** value) const { |
| 14 return prefs_.GetValue(key, value) ? READ_OK : READ_NO_VALUE; | 18 return prefs_.GetValue(key, value) ? READ_OK : READ_NO_VALUE; |
| 15 } | 19 } |
| 16 | 20 |
| 17 void ValueMapPrefStore::AddObserver(PrefStore::Observer* observer) { | 21 void ValueMapPrefStore::AddObserver(PrefStore::Observer* observer) { |
| 18 observers_.AddObserver(observer); | 22 observers_.AddObserver(observer); |
| 19 } | 23 } |
| 20 | 24 |
| 21 void ValueMapPrefStore::RemoveObserver(PrefStore::Observer* observer) { | 25 void ValueMapPrefStore::RemoveObserver(PrefStore::Observer* observer) { |
| 22 observers_.RemoveObserver(observer); | 26 observers_.RemoveObserver(observer); |
| 23 } | 27 } |
| 24 | 28 |
| 25 void ValueMapPrefStore::SetValue(const std::string& key, Value* value) { | 29 void ValueMapPrefStore::SetValue(const std::string& key, Value* value) { |
| 26 if (prefs_.SetValue(key, value)) | 30 if (prefs_.SetValue(key, value)) |
| 27 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 31 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 28 } | 32 } |
| 29 | 33 |
| 30 void ValueMapPrefStore::RemoveValue(const std::string& key) { | 34 void ValueMapPrefStore::RemoveValue(const std::string& key) { |
| 31 if (prefs_.RemoveValue(key)) | 35 if (prefs_.RemoveValue(key)) |
| 32 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 36 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 33 } | 37 } |
| 34 | 38 |
| 35 void ValueMapPrefStore::NotifyInitializationCompleted() { | 39 void ValueMapPrefStore::NotifyInitializationCompleted() { |
| 36 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted()); | 40 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted()); |
| 37 } | 41 } |
| OLD | NEW |