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

Side by Side Diff: components/prefs/pref_filter.h

Issue 1907043002: Convert //components/prefs from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU fixes Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_PREFS_PREF_FILTER_H_ 5 #ifndef COMPONENTS_PREFS_PREF_FILTER_H_
6 #define COMPONENTS_PREFS_PREF_FILTER_H_ 6 #define COMPONENTS_PREFS_PREF_FILTER_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/prefs/base_prefs_export.h" 12 #include "components/prefs/base_prefs_export.h"
13 13
14 namespace base { 14 namespace base {
15 class DictionaryValue; 15 class DictionaryValue;
16 class Value; 16 class Value;
17 } // namespace base 17 } // namespace base
18 18
19 // Filters preferences as they are loaded from disk or updated at runtime. 19 // Filters preferences as they are loaded from disk or updated at runtime.
20 // Currently supported only by JsonPrefStore. 20 // Currently supported only by JsonPrefStore.
21 class COMPONENTS_PREFS_EXPORT PrefFilter { 21 class COMPONENTS_PREFS_EXPORT PrefFilter {
22 public: 22 public:
23 // A callback to be invoked when |prefs| have been read (and possibly 23 // A callback to be invoked when |prefs| have been read (and possibly
24 // pre-modified) and are now ready to be handed back to this callback's 24 // pre-modified) and are now ready to be handed back to this callback's
25 // builder. |schedule_write| indicates whether a write should be immediately 25 // builder. |schedule_write| indicates whether a write should be immediately
26 // scheduled (typically because the |prefs| were pre-modified). 26 // scheduled (typically because the |prefs| were pre-modified).
27 typedef base::Callback<void(scoped_ptr<base::DictionaryValue> prefs, 27 typedef base::Callback<void(std::unique_ptr<base::DictionaryValue> prefs,
28 bool schedule_write)> PostFilterOnLoadCallback; 28 bool schedule_write)>
29 PostFilterOnLoadCallback;
29 30
30 virtual ~PrefFilter() {} 31 virtual ~PrefFilter() {}
31 32
32 // This method is given ownership of the |pref_store_contents| read from disk 33 // This method is given ownership of the |pref_store_contents| read from disk
33 // before the underlying PersistentPrefStore gets to use them. It must hand 34 // before the underlying PersistentPrefStore gets to use them. It must hand
34 // them back via |post_filter_on_load_callback|, but may modify them first. 35 // them back via |post_filter_on_load_callback|, but may modify them first.
35 // Note: This method is asynchronous, which may make calls like 36 // Note: This method is asynchronous, which may make calls like
36 // PersistentPrefStore::ReadPrefs() asynchronous. The owner of filtered 37 // PersistentPrefStore::ReadPrefs() asynchronous. The owner of filtered
37 // PersistentPrefStores should handle this to make the reads look synchronous 38 // PersistentPrefStores should handle this to make the reads look synchronous
38 // to external users (see SegregatedPrefStore::ReadPrefs() for an example). 39 // to external users (see SegregatedPrefStore::ReadPrefs() for an example).
39 virtual void FilterOnLoad( 40 virtual void FilterOnLoad(
40 const PostFilterOnLoadCallback& post_filter_on_load_callback, 41 const PostFilterOnLoadCallback& post_filter_on_load_callback,
41 scoped_ptr<base::DictionaryValue> pref_store_contents) = 0; 42 std::unique_ptr<base::DictionaryValue> pref_store_contents) = 0;
42 43
43 // Receives notification when a pref store value is changed, before Observers 44 // Receives notification when a pref store value is changed, before Observers
44 // are notified. 45 // are notified.
45 virtual void FilterUpdate(const std::string& path) = 0; 46 virtual void FilterUpdate(const std::string& path) = 0;
46 47
47 // Receives notification when the pref store is about to serialize data 48 // Receives notification when the pref store is about to serialize data
48 // contained in |pref_store_contents| to a string. Modifications to 49 // contained in |pref_store_contents| to a string. Modifications to
49 // |pref_store_contents| will be persisted to disk and also affect the 50 // |pref_store_contents| will be persisted to disk and also affect the
50 // in-memory state. 51 // in-memory state.
51 virtual void FilterSerializeData( 52 virtual void FilterSerializeData(
52 base::DictionaryValue* pref_store_contents) = 0; 53 base::DictionaryValue* pref_store_contents) = 0;
53 }; 54 };
54 55
55 #endif // COMPONENTS_PREFS_PREF_FILTER_H_ 56 #endif // COMPONENTS_PREFS_PREF_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698