| 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 #ifndef BASE_PREFS_TESTING_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_TESTING_PREF_STORE_H_ |
| 6 #define BASE_PREFS_TESTING_PREF_STORE_H_ | 6 #define BASE_PREFS_TESTING_PREF_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" |
| 12 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 13 #include "base/prefs/persistent_pref_store.h" | 15 #include "base/prefs/persistent_pref_store.h" |
| 14 #include "base/prefs/pref_value_map.h" | 16 #include "base/prefs/pref_value_map.h" |
| 15 | 17 |
| 16 // |TestingPrefStore| is a preference store implementation that allows tests to | 18 // |TestingPrefStore| is a preference store implementation that allows tests to |
| 17 // explicitly manipulate the contents of the store, triggering notifications | 19 // explicitly manipulate the contents of the store, triggering notifications |
| 18 // where appropriate. | 20 // where appropriate. |
| 19 class TestingPrefStore : public PersistentPrefStore { | 21 class TestingPrefStore : public PersistentPrefStore { |
| 20 public: | 22 public: |
| 21 TestingPrefStore(); | 23 TestingPrefStore(); |
| 22 | 24 |
| 23 // Overriden from PrefStore. | 25 // Overriden from PrefStore. |
| 24 bool GetValue(const std::string& key, | 26 bool GetValue(const std::string& key, |
| 25 const base::Value** result) const override; | 27 const base::Value** result) const override; |
| 26 void AddObserver(PrefStore::Observer* observer) override; | 28 void AddObserver(PrefStore::Observer* observer) override; |
| 27 void RemoveObserver(PrefStore::Observer* observer) override; | 29 void RemoveObserver(PrefStore::Observer* observer) override; |
| 28 bool HasObservers() const override; | 30 bool HasObservers() const override; |
| 29 bool IsInitializationComplete() const override; | 31 bool IsInitializationComplete() const override; |
| 30 | 32 |
| 31 // PersistentPrefStore overrides: | 33 // PersistentPrefStore overrides: |
| 32 bool GetMutableValue(const std::string& key, base::Value** result) override; | 34 bool GetMutableValue(const std::string& key, base::Value** result) override; |
| 33 void ReportValueChanged(const std::string& key, uint32 flags) override; | 35 void ReportValueChanged(const std::string& key, uint32_t flags) override; |
| 34 void SetValue(const std::string& key, | 36 void SetValue(const std::string& key, |
| 35 scoped_ptr<base::Value> value, | 37 scoped_ptr<base::Value> value, |
| 36 uint32 flags) override; | 38 uint32_t flags) override; |
| 37 void SetValueSilently(const std::string& key, | 39 void SetValueSilently(const std::string& key, |
| 38 scoped_ptr<base::Value> value, | 40 scoped_ptr<base::Value> value, |
| 39 uint32 flags) override; | 41 uint32_t flags) override; |
| 40 void RemoveValue(const std::string& key, uint32 flags) override; | 42 void RemoveValue(const std::string& key, uint32_t flags) override; |
| 41 bool ReadOnly() const override; | 43 bool ReadOnly() const override; |
| 42 PrefReadError GetReadError() const override; | 44 PrefReadError GetReadError() const override; |
| 43 PersistentPrefStore::PrefReadError ReadPrefs() override; | 45 PersistentPrefStore::PrefReadError ReadPrefs() override; |
| 44 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; | 46 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; |
| 45 void CommitPendingWrite() override; | 47 void CommitPendingWrite() override; |
| 46 void SchedulePendingLossyWrites() override; | 48 void SchedulePendingLossyWrites() override; |
| 47 | 49 |
| 48 // Marks the store as having completed initialization. | 50 // Marks the store as having completed initialization. |
| 49 void SetInitializationCompleted(); | 51 void SetInitializationCompleted(); |
| 50 | 52 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // mutation. | 105 // mutation. |
| 104 bool committed_; | 106 bool committed_; |
| 105 | 107 |
| 106 scoped_ptr<ReadErrorDelegate> error_delegate_; | 108 scoped_ptr<ReadErrorDelegate> error_delegate_; |
| 107 base::ObserverList<PrefStore::Observer, true> observers_; | 109 base::ObserverList<PrefStore::Observer, true> observers_; |
| 108 | 110 |
| 109 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); | 111 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 #endif // BASE_PREFS_TESTING_PREF_STORE_H_ | 114 #endif // BASE_PREFS_TESTING_PREF_STORE_H_ |
| OLD | NEW |