Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / base / prefs / pref_filter.h
index 0cf78a9..1020029 100644 (file)
@@ -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,13 +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.
-  virtual void 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.