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

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

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.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/process/BUILD.gn » ('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 2014 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 BASE_PREFS_WRITEABLE_PREF_STORE_H_
6 #define BASE_PREFS_WRITEABLE_PREF_STORE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/prefs/pref_store.h"
13
14 namespace base {
15 class Value;
16 }
17
18 // A pref store that can be written to as well as read from.
19 class BASE_PREFS_EXPORT WriteablePrefStore : public PrefStore {
20 public:
21 // PrefWriteFlags can be used to change the way a pref will be written to
22 // storage.
23 enum PrefWriteFlags : uint32 {
24 // No flags are specified.
25 DEFAULT_PREF_WRITE_FLAGS = 0,
26
27 // This marks the pref as "lossy". There is no strict time guarantee on when
28 // a lossy pref will be persisted to permanent storage when it is modified.
29 LOSSY_PREF_WRITE_FLAG = 1 << 1
30 };
31
32 WriteablePrefStore() {}
33
34 // Sets a |value| for |key| in the store. |value| must be non-NULL. |flags| is
35 // a bitmask of PrefWriteFlags.
36 virtual void SetValue(const std::string& key,
37 scoped_ptr<base::Value> value,
38 uint32 flags) = 0;
39
40 // Removes the value for |key|.
41 virtual void RemoveValue(const std::string& key, uint32 flags) = 0;
42
43 // Equivalent to PrefStore::GetValue but returns a mutable value.
44 virtual bool GetMutableValue(const std::string& key,
45 base::Value** result) = 0;
46
47 // Triggers a value changed notification. This function needs to be called
48 // if one retrieves a list or dictionary with GetMutableValue and change its
49 // value. SetValue takes care of notifications itself. Note that
50 // ReportValueChanged will trigger notifications even if nothing has changed.
51 // |flags| is a bitmask of PrefWriteFlags.
52 virtual void ReportValueChanged(const std::string& key, uint32 flags) = 0;
53
54 // Same as SetValue, but doesn't generate notifications. This is used by
55 // PrefService::GetMutableUserPref() in order to put empty entries
56 // into the user pref store. Using SetValue is not an option since existing
57 // tests rely on the number of notifications generated. |flags| is a bitmask
58 // of PrefWriteFlags.
59 virtual void SetValueSilently(const std::string& key,
60 scoped_ptr<base::Value> value,
61 uint32 flags) = 0;
62
63 protected:
64 ~WriteablePrefStore() override {}
65
66 private:
67 DISALLOW_COPY_AND_ASSIGN(WriteablePrefStore);
68 };
69
70 #endif // BASE_PREFS_WRITEABLE_PREF_STORE_H_
OLDNEW
« no previous file with comments | « base/prefs/value_map_pref_store.cc ('k') | base/process/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698