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

Unified Diff: base/files/important_file_writer.h

Issue 2299523003: Add synchronous callback support to important_file_writer.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: on_successful_write -> OnNextSuccessfulWrite for consistency 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') | base/files/important_file_writer.cc » ('J')
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 6e8646af3dab1de60cdaba572ce059987932835c..6265869caf0d47aa6bdc744b96a959a0d5b1e84d 100644
--- a/base/files/important_file_writer.h
+++ b/base/files/important_file_writer.h
@@ -94,10 +94,18 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe {
// Serialize data pending to be saved and execute write on backend thread.
void DoScheduledWrite();
- // Registers |on_next_successful_write| to be called once, on the next
- // successful write event. Only one callback can be set at once.
- void RegisterOnNextSuccessfulWriteCallback(
- const Closure& on_next_successful_write);
+ // Registers |on_next_successful_write_reply| to be invoked on the sequence
+ // owning this ImportantFileWriter in reply to the next successful write.
+ // Only one such callback can be set at once.
+ void RegisterOnNextSuccessfulWriteReply(
+ const Closure& on_next_successful_write_reply);
+
+ // 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.
+ // Only one such callback can be set at once.
+ void RegisterOnNextWriteSynchronousCallback(
+ const Callback<void(bool success)>& on_next_write_callback);
TimeDelta commit_interval() const {
return commit_interval_;
@@ -112,7 +120,10 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe {
void ForwardSuccessfulWrite(bool result);
// Invoked once and then reset on the next successful write event.
- Closure on_next_successful_write_;
+ Closure on_next_successful_write_reply_;
+
+ // Invoked synchronously on the next write event.
+ Callback<void(bool success)> on_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') | base/files/important_file_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698