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

Side by Side Diff: base/prefs/writeable_pref_store.h

Issue 1648403002: Move base/prefs to components/prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « base/prefs/value_map_pref_store.cc ('k') | base/test/data/prefs/invalid.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_WRITEABLE_PREF_STORE_H_ 5 // TODO(brettw) remove this forwarding header when prefs is completely moved to
6 #define BASE_PREFS_WRITEABLE_PREF_STORE_H_ 6 // components.
7 7 #include "components/prefs/writeable_pref_store.h"
8 #include <stdint.h>
9
10 #include <string>
11
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/prefs/pref_store.h"
15
16 namespace base {
17 class Value;
18 }
19
20 // A pref store that can be written to as well as read from.
21 class BASE_PREFS_EXPORT WriteablePrefStore : public PrefStore {
22 public:
23 // PrefWriteFlags can be used to change the way a pref will be written to
24 // storage.
25 enum PrefWriteFlags : uint32_t {
26 // No flags are specified.
27 DEFAULT_PREF_WRITE_FLAGS = 0,
28
29 // This marks the pref as "lossy". There is no strict time guarantee on when
30 // a lossy pref will be persisted to permanent storage when it is modified.
31 LOSSY_PREF_WRITE_FLAG = 1 << 1
32 };
33
34 WriteablePrefStore() {}
35
36 // Sets a |value| for |key| in the store. |value| must be non-NULL. |flags| is
37 // a bitmask of PrefWriteFlags.
38 virtual void SetValue(const std::string& key,
39 scoped_ptr<base::Value> value,
40 uint32_t flags) = 0;
41
42 // Removes the value for |key|.
43 virtual void RemoveValue(const std::string& key, uint32_t flags) = 0;
44
45 // Equivalent to PrefStore::GetValue but returns a mutable value.
46 virtual bool GetMutableValue(const std::string& key,
47 base::Value** result) = 0;
48
49 // Triggers a value changed notification. This function needs to be called
50 // if one retrieves a list or dictionary with GetMutableValue and change its
51 // value. SetValue takes care of notifications itself. Note that
52 // ReportValueChanged will trigger notifications even if nothing has changed.
53 // |flags| is a bitmask of PrefWriteFlags.
54 virtual void ReportValueChanged(const std::string& key, uint32_t flags) = 0;
55
56 // Same as SetValue, but doesn't generate notifications. This is used by
57 // PrefService::GetMutableUserPref() in order to put empty entries
58 // into the user pref store. Using SetValue is not an option since existing
59 // tests rely on the number of notifications generated. |flags| is a bitmask
60 // of PrefWriteFlags.
61 virtual void SetValueSilently(const std::string& key,
62 scoped_ptr<base::Value> value,
63 uint32_t flags) = 0;
64
65 protected:
66 ~WriteablePrefStore() override {}
67
68 private:
69 DISALLOW_COPY_AND_ASSIGN(WriteablePrefStore);
70 };
71
72 #endif // BASE_PREFS_WRITEABLE_PREF_STORE_H_
OLDNEW
« no previous file with comments | « base/prefs/value_map_pref_store.cc ('k') | base/test/data/prefs/invalid.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698