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

Unified Diff: components/prefs/pref_filter.h

Issue 2372663003: Allow ImportantFileWriter to take in a pre-write callback. (Closed)
Patch Set: Add a WaitableEvent to fix a race condition in CallbackRunsOnWriterThread Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/prefs/json_pref_store_unittest.cc ('k') | components/user_prefs/tracked/pref_hash_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/pref_filter.h
diff --git a/components/prefs/pref_filter.h b/components/prefs/pref_filter.h
index 6ca2197618329bc12a2bd26bf4eaa3c0822b8138..82be63e0aee10a1055191a304af978be45ddf6d4 100644
--- a/components/prefs/pref_filter.h
+++ b/components/prefs/pref_filter.h
@@ -7,6 +7,7 @@
#include <memory>
#include <string>
+#include <utility>
#include "base/callback_forward.h"
#include "components/prefs/base_prefs_export.h"
@@ -20,13 +21,17 @@ class Value;
// Currently supported only by JsonPrefStore.
class COMPONENTS_PREFS_EXPORT PrefFilter {
public:
+ // A pair of pre-write and post-write callbacks.
+ using OnWriteCallbackPair =
+ std::pair<base::Closure, base::Callback<void(bool success)>>;
+
// 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(std::unique_ptr<base::DictionaryValue> prefs,
- bool schedule_write)>
- PostFilterOnLoadCallback;
+ using PostFilterOnLoadCallback =
+ base::Callback<void(std::unique_ptr<base::DictionaryValue> prefs,
+ bool schedule_write)>;
virtual ~PrefFilter() {}
@@ -49,7 +54,10 @@ class COMPONENTS_PREFS_EXPORT PrefFilter {
// contained in |pref_store_contents| to a string. Modifications to
// |pref_store_contents| will be persisted to disk and also affect the
// in-memory state.
- virtual void FilterSerializeData(
+ // If the returned callbacks are non-null, they will be registered to be
+ // invoked synchronously after the next write (from the I/O TaskRunner so they
+ // must not be bound to thread-unsafe member state).
+ virtual OnWriteCallbackPair FilterSerializeData(
base::DictionaryValue* pref_store_contents) = 0;
};
« no previous file with comments | « components/prefs/json_pref_store_unittest.cc ('k') | components/user_prefs/tracked/pref_hash_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698