| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 virtual ReadResult GetMutableValue(const std::string& key, | 31 virtual ReadResult GetMutableValue(const std::string& key, |
| 32 base::Value** result) OVERRIDE; | 32 base::Value** result) OVERRIDE; |
| 33 virtual void ReportValueChanged(const std::string& key) OVERRIDE; | 33 virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
| 34 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; | 34 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
| 35 virtual void SetValueSilently(const std::string& key, | 35 virtual void SetValueSilently(const std::string& key, |
| 36 base::Value* value) OVERRIDE; | 36 base::Value* value) OVERRIDE; |
| 37 virtual void RemoveValue(const std::string& key) OVERRIDE; | 37 virtual void RemoveValue(const std::string& key) OVERRIDE; |
| 38 virtual bool ReadOnly() const OVERRIDE; | 38 virtual bool ReadOnly() const OVERRIDE; |
| 39 virtual PersistentPrefStore::PrefReadError ReadPrefs() OVERRIDE; | 39 virtual PersistentPrefStore::PrefReadError ReadPrefs() OVERRIDE; |
| 40 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; | 40 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; |
| 41 virtual bool WritePrefs() OVERRIDE; | |
| 42 virtual void ScheduleWritePrefs() OVERRIDE {} | |
| 43 virtual void CommitPendingWrite() OVERRIDE {} | 41 virtual void CommitPendingWrite() OVERRIDE {} |
| 44 | 42 |
| 45 // Marks the store as having completed initialization. | 43 // Marks the store as having completed initialization. |
| 46 void SetInitializationCompleted(); | 44 void SetInitializationCompleted(); |
| 47 | 45 |
| 48 // Used for tests to trigger notifications explicitly. | 46 // Used for tests to trigger notifications explicitly. |
| 49 void NotifyPrefValueChanged(const std::string& key); | 47 void NotifyPrefValueChanged(const std::string& key); |
| 50 void NotifyInitializationCompleted(); | 48 void NotifyInitializationCompleted(); |
| 51 | 49 |
| 52 // Some convenience getters/setters. | 50 // Some convenience getters/setters. |
| 53 void SetString(const std::string& key, const std::string& value); | 51 void SetString(const std::string& key, const std::string& value); |
| 54 void SetInteger(const std::string& key, int value); | 52 void SetInteger(const std::string& key, int value); |
| 55 void SetBoolean(const std::string& key, bool value); | 53 void SetBoolean(const std::string& key, bool value); |
| 56 | 54 |
| 57 bool GetString(const std::string& key, std::string* value) const; | 55 bool GetString(const std::string& key, std::string* value) const; |
| 58 bool GetInteger(const std::string& key, int* value) const; | 56 bool GetInteger(const std::string& key, int* value) const; |
| 59 bool GetBoolean(const std::string& key, bool* value) const; | 57 bool GetBoolean(const std::string& key, bool* value) const; |
| 60 | 58 |
| 61 // Getter and Setter methods for setting and getting the state of the | 59 // Getter and Setter methods for setting and getting the state of the |
| 62 // |TestingPrefStore|. | 60 // |TestingPrefStore|. |
| 63 virtual void set_read_only(bool read_only); | 61 virtual void set_read_only(bool read_only); |
| 64 virtual void set_prefs_written(bool status); | |
| 65 virtual bool get_prefs_written(); | |
| 66 | 62 |
| 67 private: | 63 private: |
| 68 // Stores the preference values. | 64 // Stores the preference values. |
| 69 PrefValueMap prefs_; | 65 PrefValueMap prefs_; |
| 70 | 66 |
| 71 // Flag that indicates if the PrefStore is read-only | 67 // Flag that indicates if the PrefStore is read-only |
| 72 bool read_only_; | 68 bool read_only_; |
| 73 | 69 |
| 74 // Flag that indicates if the method WritePrefs was called. | 70 // Flag that indicates if the method WritePrefs was called. |
| 75 bool prefs_written_; | 71 bool prefs_written_; |
| 76 | 72 |
| 77 // Whether initialization has been completed. | 73 // Whether initialization has been completed. |
| 78 bool init_complete_; | 74 bool init_complete_; |
| 79 | 75 |
| 80 ObserverList<PrefStore::Observer, true> observers_; | 76 ObserverList<PrefStore::Observer, true> observers_; |
| 81 | 77 |
| 82 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); | 78 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore); |
| 83 }; | 79 }; |
| 84 | 80 |
| 85 #endif // CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ | 81 #endif // CHROME_BROWSER_PREFS_TESTING_PREF_STORE_H_ |
| OLD | NEW |