Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: chrome/common/persistent_pref_store.h

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrefService mock construction in PrefServiceTest to include command line store. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/json_pref_store_unittest.cc ('k') | chrome/common/pref_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 complementary to the PrefStore interface, declaring
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|, which
38 // must be non-NULL.
39 virtual void SetValue(const std::string& key, Value* value) = 0;
40
41 // Same as SetValue, but doesn't generate notifications. This is used by
42 // GetMutableDictionary() and GetMutableList() in order to put empty entries
43 // into the user pref store. Using SetValue is not an option since existing
44 // tests rely on the number of notifications generated.
45 //
46 // TODO(mnissler, danno): Can we replace GetMutableDictionary() and
47 // GetMutableList() with something along the lines of ScopedPrefUpdate that
48 // updates the value in the end?
49 virtual void SetValueSilently(const std::string& key, Value* value) = 0;
50
51 // Removes the value for |key|.
52 virtual void RemoveValue(const std::string& key) = 0;
53
54 // Whether the store is in a pseudo-read-only mode where changes are not
55 // actually persisted to disk. This happens in some cases when there are
56 // read errors during startup.
57 virtual bool ReadOnly() const = 0;
58
59 // Reads the preferences from disk.
60 virtual PrefReadError ReadPrefs() = 0;
61
62 // Writes the preferences to disk immediately.
63 virtual bool WritePrefs() = 0;
64
65 // Schedules an asynchronous write operation.
66 virtual void ScheduleWritePrefs() = 0;
67 };
68
69 #endif // CHROME_COMMON_PERSISTENT_PREF_STORE_H_
OLDNEW
« no previous file with comments | « chrome/common/json_pref_store_unittest.cc ('k') | chrome/common/pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698