OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ |
6 #define CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ | 6 #define CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "chrome/browser/prefs/pref_value_map.h" | 12 #include "chrome/browser/prefs/pref_value_map.h" |
13 #include "chrome/common/persistent_pref_store.h" | 13 #include "chrome/common/persistent_pref_store.h" |
14 | 14 |
15 class DictionaryValue; | |
16 | |
17 // |TestingPrefStore| is a preference store implementation that allows tests to | 15 // |TestingPrefStore| is a preference store implementation that allows tests to |
18 // explicitly manipulate the contents of the store, triggering notifications | 16 // explicitly manipulate the contents of the store, triggering notifications |
19 // where appropriate. | 17 // where appropriate. |
20 class TestingPrefStore : public PersistentPrefStore { | 18 class TestingPrefStore : public PersistentPrefStore { |
21 public: | 19 public: |
22 TestingPrefStore(); | 20 TestingPrefStore(); |
23 virtual ~TestingPrefStore(); | 21 virtual ~TestingPrefStore(); |
24 | 22 |
25 // Overriden from PrefStore. | 23 // Overriden from PrefStore. |
26 virtual ReadResult GetValue(const std::string& key, | 24 virtual ReadResult GetValue(const std::string& key, |
27 const Value** result) const; | 25 const base::Value** result) const; |
28 virtual void AddObserver(PrefStore::Observer* observer); | 26 virtual void AddObserver(PrefStore::Observer* observer); |
29 virtual void RemoveObserver(PrefStore::Observer* observer); | 27 virtual void RemoveObserver(PrefStore::Observer* observer); |
30 virtual bool IsInitializationComplete() const; | 28 virtual bool IsInitializationComplete() const; |
31 | 29 |
32 // PersistentPrefStore overrides: | 30 // PersistentPrefStore overrides: |
33 virtual ReadResult GetMutableValue(const std::string& key, Value** result); | 31 virtual ReadResult GetMutableValue(const std::string& key, |
| 32 base::Value** result); |
34 virtual void ReportValueChanged(const std::string& key); | 33 virtual void ReportValueChanged(const std::string& key); |
35 virtual void SetValue(const std::string& key, Value* value); | 34 virtual void SetValue(const std::string& key, base::Value* value); |
36 virtual void SetValueSilently(const std::string& key, Value* value); | 35 virtual void SetValueSilently(const std::string& key, base::Value* value); |
37 virtual void RemoveValue(const std::string& key); | 36 virtual void RemoveValue(const std::string& key); |
38 virtual bool ReadOnly() const; | 37 virtual bool ReadOnly() const; |
39 virtual PersistentPrefStore::PrefReadError ReadPrefs(); | 38 virtual PersistentPrefStore::PrefReadError ReadPrefs(); |
40 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate); | 39 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate); |
41 virtual bool WritePrefs(); | 40 virtual bool WritePrefs(); |
42 virtual void ScheduleWritePrefs() {} | 41 virtual void ScheduleWritePrefs() {} |
43 virtual void CommitPendingWrite() {} | 42 virtual void CommitPendingWrite() {} |
44 | 43 |
45 // Marks the store as having completed initialization. | 44 // Marks the store as having completed initialization. |
46 void SetInitializationCompleted(); | 45 void SetInitializationCompleted(); |
(...skipping 29 matching lines...) Expand all Loading... |
76 | 75 |
77 // Whether initialization has been completed. | 76 // Whether initialization has been completed. |
78 bool init_complete_; | 77 bool init_complete_; |
79 | 78 |
80 ObserverList<PrefStore::Observer, true> observers_; | 79 ObserverList<PrefStore::Observer, true> observers_; |
81 | 80 |
82 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); | 81 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); |
83 }; | 82 }; |
84 | 83 |
85 #endif // CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ | 84 #endif // CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ |
OLD | NEW |