Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_PERSISTENT_PREF_STORE_H_ | |
| 6 #define CHROME_COMMON_PERSISTENT_PREF_STORE_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include <chrome/common/pref_store.h> | |
| 12 | |
| 13 // This interface is a complement to the PrefStore interface, declaring | |
|
danno
2010/12/08 13:08:45
s/a complement/complimentary/
danno
2010/12/08 13:21:00
Whoops, sorry, should be complementary :-)
On 2010
Mattias Nissler (ping if slow)
2010/12/09 10:20:20
Done.
| |
| 14 // additional functionatliy that adds support for setting values and persisting | |
| 15 // the data to some backing store. | |
| 16 class PersistentPrefStore : public PrefStore { | |
| 17 public: | |
| 18 virtual ~PersistentPrefStore() {} | |
| 19 | |
| 20 // Unique integer code for each type of error so we can report them | |
| 21 // distinctly in a histogram. | |
| 22 // NOTE: Don't change the order here as it will change the server's meaning | |
| 23 // of the histogram. | |
| 24 enum PrefReadError { | |
| 25 PREF_READ_ERROR_NONE = 0, | |
| 26 PREF_READ_ERROR_JSON_PARSE, | |
| 27 PREF_READ_ERROR_JSON_TYPE, | |
| 28 PREF_READ_ERROR_ACCESS_DENIED, | |
| 29 PREF_READ_ERROR_FILE_OTHER, | |
| 30 PREF_READ_ERROR_FILE_LOCKED, | |
| 31 PREF_READ_ERROR_NO_FILE, | |
| 32 PREF_READ_ERROR_JSON_REPEAT, | |
| 33 PREF_READ_ERROR_OTHER, | |
| 34 PREF_READ_ERROR_FILE_NOT_SPECIFIED | |
| 35 }; | |
| 36 | |
| 37 // Sets a |value| for |key| in the store. Assumes ownership of |value|. | |
| 38 virtual void SetValue(const std::string& key, Value* value) = 0; | |
| 39 | |
| 40 // Same as SetValue, but doesn't generate notifications. This is used by | |
| 41 // GetMutableDictionary() and GetMutableList() in order to put empty entries | |
| 42 // into the user pref store. Using SetValue is not an options since existing | |
|
gfeher
2010/12/08 12:34:35
s/options/option/
Mattias Nissler (ping if slow)
2010/12/09 10:20:20
Done.
| |
| 43 // tests rely on the number of notifications generated. | |
| 44 // | |
| 45 // TODO(mnissler, danno): Can we replace GetMutableDictionary() and | |
| 46 // GetMutableList() with something along the lines of ScopedPrefUpdate that | |
| 47 // updates the value in the end? | |
| 48 virtual void SetValueSilently(const std::string& key, Value* value) = 0; | |
|
battre (please use the other)
2010/12/08 12:24:15
value==NULL is remove?
Mattias Nissler (ping if slow)
2010/12/09 10:20:20
Added a comment saying that value must be non-NULL
| |
| 49 | |
| 50 // Removes the value for |key|. | |
| 51 virtual void RemoveValue(const std::string& key) = 0; | |
| 52 | |
| 53 // Whether the store is in a pseudo-read-only mode where changes are not | |
| 54 // actually persisted to disk. This happens in some cases when there are | |
| 55 // read errors during startup. | |
| 56 virtual bool ReadOnly() const = 0; | |
| 57 | |
| 58 // Reads the preferences from disk. | |
| 59 virtual PrefReadError ReadPrefs() = 0; | |
| 60 | |
| 61 // Writes the preferences to disk immediately. | |
| 62 virtual bool WritePrefs() = 0; | |
| 63 | |
| 64 // Schedules an asynchronous write operation. | |
| 65 virtual void ScheduleWritePrefs() = 0; | |
| 66 }; | |
| 67 | |
| 68 #endif // CHROME_COMMON_PERSISTENT_PREF_STORE_H_ | |
| OLD | NEW |