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

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

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

Powered by Google App Engine
This is Rietveld 408576698