Index: base/prefs/pref_filter.h |
diff --git a/base/prefs/pref_filter.h b/base/prefs/pref_filter.h |
index ce07f929c7a7fc94f1569f66d3e403eee0f3c355..1020029131ab3daaec1f3abbfa322781915d9abf 100644 |
--- a/base/prefs/pref_filter.h |
+++ b/base/prefs/pref_filter.h |
@@ -7,6 +7,8 @@ |
#include <string> |
+#include "base/callback_forward.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/prefs/base_prefs_export.h" |
namespace base { |
@@ -18,15 +20,25 @@ class Value; |
// Currently supported only by JsonPrefStore. |
class BASE_PREFS_EXPORT PrefFilter { |
public: |
+ // A callback to be invoked when |prefs| have been read (and possibly |
+ // pre-modified) and are now ready to be handed back to this callback's |
+ // builder. |schedule_write| indicates whether a write should be immediately |
+ // scheduled (typically because the |prefs| were pre-modified). |
+ typedef base::Callback<void(scoped_ptr<base::DictionaryValue> prefs, |
+ bool schedule_write)> PostFilterOnLoadCallback; |
+ |
virtual ~PrefFilter() {} |
- // Receives notification when the pref store data has been loaded but before |
- // Observers are notified. |
- // Changes made by a PrefFilter during FilterOnLoad do not result in |
- // notifications to |PrefStore::Observer|s. |
- // Implementations should return true if they modify the dictionary, to allow |
- // the changes to be persisted. |
- virtual bool FilterOnLoad(base::DictionaryValue* pref_store_contents) = 0; |
+ // This method is given ownership of the |pref_store_contents| read from disk |
+ // before the underlying PersistentPrefStore gets to use them. It must hand |
+ // them back via |post_filter_on_load_callback|, but may modify them first. |
+ // Note: This method is asynchronous, which may make calls like |
+ // PersistentPrefStore::ReadPrefs() asynchronous. The owner of filtered |
+ // PersistentPrefStores should handle this to make the reads look synchronous |
+ // to external users (see SegregatedPrefStore::ReadPrefs() for an example). |
+ virtual void FilterOnLoad( |
+ const PostFilterOnLoadCallback& post_filter_on_load_callback, |
+ scoped_ptr<base::DictionaryValue> pref_store_contents) = 0; |
// Receives notification when a pref store value is changed, before Observers |
// are notified. |