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

Unified Diff: base/files/important_file_writer.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 | « no previous file | base/files/important_file_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/important_file_writer.h
diff --git a/base/files/important_file_writer.h b/base/files/important_file_writer.h
index cd724e326691a2d1e2516b2ffd1859c78bb86946..8823a9c7670c0ba27f5752d0984c93d4c3dae6ef 100644
--- a/base/files/important_file_writer.h
+++ b/base/files/important_file_writer.h
@@ -94,15 +94,17 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe {
// Serialize data pending to be saved and execute write on backend thread.
void DoScheduledWrite();
- // Registers |on_next_write_callback| to be synchronously invoked from
- // WriteFileAtomically() on its next write (i.e. from |task_runner_|), with
- // |success| indicating whether it succeeded or not.
- // |on_next_write_callback| must be thread safe, as it will be called on
- // |task_runner_| and may be called during Chrome shutdown.
+ // Registers |before_next_write_callback| and |after_next_write_callback| to
+ // be synchronously invoked from WriteFileAtomically() before its next write
+ // and after its next write, respectively. The boolean passed to
+ // |after_next_write_callback| indicates whether the write was successful.
+ // Both callbacks must be thread safe as they will be called on |task_runner_|
+ // and may be called during Chrome shutdown.
// If called more than once before a write is scheduled on |task_runner|, the
- // latest callback clobbers the others.
- void RegisterOnNextWriteCallback(
- const Callback<void(bool success)>& on_next_write_callback);
+ // latest callbacks clobber the others.
+ void RegisterOnNextWriteCallbacks(
+ const Closure& before_next_write_callback,
+ const Callback<void(bool success)>& after_next_write_callback);
TimeDelta commit_interval() const {
return commit_interval_;
@@ -110,7 +112,8 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe {
private:
// Invoked synchronously on the next write event.
- Callback<void(bool success)> on_next_write_callback_;
+ Closure before_next_write_callback_;
+ Callback<void(bool success)> after_next_write_callback_;
// Path being written to.
const FilePath path_;
« no previous file with comments | « no previous file | base/files/important_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698