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_COMMON_PERSISTENT_PREF_STORE_H_ | 5 #ifndef CHROME_COMMON_PERSISTENT_PREF_STORE_H_ |
6 #define CHROME_COMMON_PERSISTENT_PREF_STORE_H_ | 6 #define CHROME_COMMON_PERSISTENT_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 PREF_READ_ERROR_JSON_TYPE, | 27 PREF_READ_ERROR_JSON_TYPE, |
28 PREF_READ_ERROR_ACCESS_DENIED, | 28 PREF_READ_ERROR_ACCESS_DENIED, |
29 PREF_READ_ERROR_FILE_OTHER, | 29 PREF_READ_ERROR_FILE_OTHER, |
30 PREF_READ_ERROR_FILE_LOCKED, | 30 PREF_READ_ERROR_FILE_LOCKED, |
31 PREF_READ_ERROR_NO_FILE, | 31 PREF_READ_ERROR_NO_FILE, |
32 PREF_READ_ERROR_JSON_REPEAT, | 32 PREF_READ_ERROR_JSON_REPEAT, |
33 PREF_READ_ERROR_OTHER, | 33 PREF_READ_ERROR_OTHER, |
34 PREF_READ_ERROR_FILE_NOT_SPECIFIED | 34 PREF_READ_ERROR_FILE_NOT_SPECIFIED |
35 }; | 35 }; |
36 | 36 |
37 class ReadErrorDelegate { | |
38 public: | |
39 virtual ~ReadErrorDelegate() {} | |
40 | |
41 virtual void OnError(PrefReadError error) = 0; | |
42 }; | |
43 | |
37 // Equivalent to PrefStore::GetValue but returns a mutable value. | 44 // Equivalent to PrefStore::GetValue but returns a mutable value. |
38 virtual ReadResult GetMutableValue(const std::string& key, | 45 virtual ReadResult GetMutableValue(const std::string& key, |
39 Value** result) = 0; | 46 Value** result) = 0; |
40 | 47 |
41 // Triggers a value changed notification. This function needs to be called | 48 // Triggers a value changed notification. This function needs to be called |
42 // if one retrieves a list or dictionary with GetMutableValue and change its | 49 // if one retrieves a list or dictionary with GetMutableValue and change its |
43 // value. SetValue takes care of notifications itself. Note that | 50 // value. SetValue takes care of notifications itself. Note that |
44 // ReportValueChanged will trigger notifications even if nothing has changed. | 51 // ReportValueChanged will trigger notifications even if nothing has changed. |
45 virtual void ReportValueChanged(const std::string& key) = 0; | 52 virtual void ReportValueChanged(const std::string& key) = 0; |
46 | 53 |
47 // Sets a |value| for |key| in the store. Assumes ownership of |value|, which | 54 // Sets a |value| for |key| in the store. Assumes ownership of |value|, which |
48 // must be non-NULL. | 55 // must be non-NULL. |
49 virtual void SetValue(const std::string& key, Value* value) = 0; | 56 virtual void SetValue(const std::string& key, Value* value) = 0; |
50 | 57 |
51 // Same as SetValue, but doesn't generate notifications. This is used by | 58 // Same as SetValue, but doesn't generate notifications. This is used by |
52 // PrefService::GetMutableUserPref() in order to put empty entries | 59 // PrefService::GetMutableUserPref() in order to put empty entries |
53 // into the user pref store. Using SetValue is not an option since existing | 60 // into the user pref store. Using SetValue is not an option since existing |
54 // tests rely on the number of notifications generated. | 61 // tests rely on the number of notifications generated. |
55 virtual void SetValueSilently(const std::string& key, Value* value) = 0; | 62 virtual void SetValueSilently(const std::string& key, Value* value) = 0; |
56 | 63 |
57 // Removes the value for |key|. | 64 // Removes the value for |key|. |
58 virtual void RemoveValue(const std::string& key) = 0; | 65 virtual void RemoveValue(const std::string& key) = 0; |
59 | 66 |
60 // Whether the store is in a pseudo-read-only mode where changes are not | 67 // Whether the store is in a pseudo-read-only mode where changes are not |
61 // actually persisted to disk. This happens in some cases when there are | 68 // actually persisted to disk. This happens in some cases when there are |
62 // read errors during startup. | 69 // read errors during startup. |
63 virtual bool ReadOnly() const = 0; | 70 virtual bool ReadOnly() const = 0; |
64 | 71 |
65 // Reads the preferences from disk. | 72 // Reads the preferences from disk. Notifies observers via |
73 // "PrefStore::OnInitializationCompleted" when done. | |
66 virtual PrefReadError ReadPrefs() = 0; | 74 virtual PrefReadError ReadPrefs() = 0; |
67 | 75 |
76 // Reads the preferences from disk asynchronously. Notifies observers via | |
77 // "PrefStore::OnInitializationCompleted" when done. Also it fires | |
Mattias Nissler (ping if slow)
2011/05/04 23:33:08
So we still have two callback mechanisms? Seems li
altimofeev
2011/05/05 12:59:28
Yes, there are two of them. But the only reason wh
Mattias Nissler (ping if slow)
2011/05/07 00:24:14
You are very right, in this case it makes sense to
| |
78 // |error_delegate| if it is not NULL and reading error has occurred. | |
79 // Owns |error_delegate|. | |
80 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) = 0; | |
81 | |
68 // Writes the preferences to disk immediately. | 82 // Writes the preferences to disk immediately. |
69 virtual bool WritePrefs() = 0; | 83 virtual bool WritePrefs() = 0; |
70 | 84 |
71 // Schedules an asynchronous write operation. | 85 // Schedules an asynchronous write operation. |
72 virtual void ScheduleWritePrefs() = 0; | 86 virtual void ScheduleWritePrefs() = 0; |
73 | 87 |
74 // Lands any pending writes to disk. | 88 // Lands any pending writes to disk. |
75 virtual void CommitPendingWrite() = 0; | 89 virtual void CommitPendingWrite() = 0; |
76 }; | 90 }; |
77 | 91 |
78 #endif // CHROME_COMMON_PERSISTENT_PREF_STORE_H_ | 92 #endif // CHROME_COMMON_PERSISTENT_PREF_STORE_H_ |
OLD | NEW |