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_PERSISTENT_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_PERSISTENT_PREF_STORE_H_ |
6 #define BASE_PREFS_PERSISTENT_PREF_STORE_H_ | 6 #define BASE_PREFS_PERSISTENT_PREF_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/prefs/base_prefs_export.h" | 10 #include "base/prefs/base_prefs_export.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 PREF_READ_ERROR_MAX_ENUM | 39 PREF_READ_ERROR_MAX_ENUM |
40 }; | 40 }; |
41 | 41 |
42 class ReadErrorDelegate { | 42 class ReadErrorDelegate { |
43 public: | 43 public: |
44 virtual ~ReadErrorDelegate() {} | 44 virtual ~ReadErrorDelegate() {} |
45 | 45 |
46 virtual void OnError(PrefReadError error) = 0; | 46 virtual void OnError(PrefReadError error) = 0; |
47 }; | 47 }; |
48 | 48 |
49 // Same as SetValue, but doesn't generate notifications. This is used by | |
50 // PrefService::GetMutableUserPref() in order to put empty entries | |
51 // into the user pref store. Using SetValue is not an option since existing | |
52 // tests rely on the number of notifications generated. | |
53 virtual void SetValueSilently(const std::string& key, base::Value* value) = 0; | |
54 | |
55 // Whether the store is in a pseudo-read-only mode where changes are not | 49 // Whether the store is in a pseudo-read-only mode where changes are not |
56 // actually persisted to disk. This happens in some cases when there are | 50 // actually persisted to disk. This happens in some cases when there are |
57 // read errors during startup. | 51 // read errors during startup. |
58 virtual bool ReadOnly() const = 0; | 52 virtual bool ReadOnly() const = 0; |
59 | 53 |
60 // Gets the read error. Only valid if IsInitializationComplete() returns true. | 54 // Gets the read error. Only valid if IsInitializationComplete() returns true. |
61 virtual PrefReadError GetReadError() const = 0; | 55 virtual PrefReadError GetReadError() const = 0; |
62 | 56 |
63 // Reads the preferences from disk. Notifies observers via | 57 // Reads the preferences from disk. Notifies observers via |
64 // "PrefStore::OnInitializationCompleted" when done. | 58 // "PrefStore::OnInitializationCompleted" when done. |
65 virtual PrefReadError ReadPrefs() = 0; | 59 virtual PrefReadError ReadPrefs() = 0; |
66 | 60 |
67 // Reads the preferences from disk asynchronously. Notifies observers via | 61 // Reads the preferences from disk asynchronously. Notifies observers via |
68 // "PrefStore::OnInitializationCompleted" when done. Also it fires | 62 // "PrefStore::OnInitializationCompleted" when done. Also it fires |
69 // |error_delegate| if it is not NULL and reading error has occurred. | 63 // |error_delegate| if it is not NULL and reading error has occurred. |
70 // Owns |error_delegate|. | 64 // Owns |error_delegate|. |
71 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) = 0; | 65 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) = 0; |
72 | 66 |
73 // Lands any pending writes to disk. | 67 // Lands any pending writes to disk. |
74 virtual void CommitPendingWrite() = 0; | 68 virtual void CommitPendingWrite() = 0; |
75 | 69 |
76 protected: | 70 protected: |
77 virtual ~PersistentPrefStore() {} | 71 virtual ~PersistentPrefStore() {} |
78 }; | 72 }; |
79 | 73 |
80 #endif // BASE_PREFS_PERSISTENT_PREF_STORE_H_ | 74 #endif // BASE_PREFS_PERSISTENT_PREF_STORE_H_ |
OLD | NEW |