OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREF_STORE_H_ |
6 #define CHROME_BROWSER_PREF_STORE_H_ | 6 #define CHROME_BROWSER_PREF_STORE_H_ |
7 | 7 |
8 class DictionaryValue; | 8 class DictionaryValue; |
9 | 9 |
10 // This is an abstract interface for reading and writing from/to a persistent | 10 // This is an abstract interface for reading and writing from/to a persistent |
11 // preference store, used by |PrefService|. An implementation using a JSON file | 11 // preference store, used by |PrefService|. An implementation using a JSON file |
12 // can be found in |JsonPrefStore|, while an implementation without any backing | 12 // can be found in |JsonPrefStore|, while an implementation without any backing |
13 // store (currently used for testing) can be found in |DummyPrefStore|. | 13 // store (currently used for testing) can be found in |DummyPrefStore|. |
14 class PrefStore { | 14 class PrefStore { |
15 public: | 15 public: |
16 // Unique integer code for each type of error so we can report them | 16 // Unique integer code for each type of error so we can report them |
17 // distinctly in a histogram. | 17 // distinctly in a histogram. |
18 // NOTE: Don't change the order here as it will change the server's meaning | 18 // NOTE: Don't change the order here as it will change the server's meaning |
19 // of the histogram. | 19 // of the histogram. |
20 enum PrefReadError { | 20 enum PrefReadError { |
21 PREF_READ_ERROR_NONE = 0, | 21 PREF_READ_ERROR_NONE = 0, |
22 PREF_READ_ERROR_JSON_PARSE, | 22 PREF_READ_ERROR_JSON_PARSE, |
23 PREF_READ_ERROR_JSON_TYPE, | 23 PREF_READ_ERROR_JSON_TYPE, |
24 PREF_READ_ERROR_ACCESS_DENIED, | 24 PREF_READ_ERROR_ACCESS_DENIED, |
25 PREF_READ_ERROR_FILE_OTHER, | 25 PREF_READ_ERROR_FILE_OTHER, |
26 PREF_READ_ERROR_FILE_LOCKED, | 26 PREF_READ_ERROR_FILE_LOCKED, |
27 PREF_READ_ERROR_NO_FILE, | 27 PREF_READ_ERROR_NO_FILE, |
28 PREF_READ_ERROR_JSON_REPEAT, | 28 PREF_READ_ERROR_JSON_REPEAT, |
| 29 PREF_READ_ERROR_OTHER |
29 }; | 30 }; |
30 | 31 |
31 virtual ~PrefStore() { } | 32 virtual ~PrefStore() { } |
32 | 33 |
33 // Whether the store is in a pseudo-read-only mode where changes are not | 34 // Whether the store is in a pseudo-read-only mode where changes are not |
34 // actually persisted to disk. This happens in some cases when there are | 35 // actually persisted to disk. This happens in some cases when there are |
35 // read errors during startup. | 36 // read errors during startup. |
36 virtual bool ReadOnly() { return true; } | 37 virtual bool ReadOnly() { return true; } |
37 | 38 |
38 virtual DictionaryValue* Prefs() = 0; | 39 virtual DictionaryValue* prefs() = 0; |
39 | 40 |
40 virtual PrefReadError ReadPrefs() = 0; | 41 virtual PrefReadError ReadPrefs() = 0; |
41 | 42 |
42 virtual bool WritePrefs() { return true; } | 43 virtual bool WritePrefs() { return true; } |
43 | 44 |
44 virtual void ScheduleWritePrefs() { } | 45 virtual void ScheduleWritePrefs() { } |
45 }; | 46 }; |
46 | 47 |
47 #endif // CHROME_BROWSER_PREF_STORE_H_ | 48 #endif // CHROME_BROWSER_PREF_STORE_H_ |
OLD | NEW |