Index: base/files/important_file_writer.h |
diff --git a/base/files/important_file_writer.h b/base/files/important_file_writer.h |
index ba1c745a4efd9fd36e4cf44b2f884c3c6c53b7b4..5534263c15cfb23c6a66f567d55289e2b38a5407 100644 |
--- a/base/files/important_file_writer.h |
+++ b/base/files/important_file_writer.h |
@@ -9,6 +9,7 @@ |
#include "base/base_export.h" |
#include "base/basictypes.h" |
+#include "base/callback.h" |
#include "base/files/file_path.h" |
#include "base/memory/ref_counted.h" |
#include "base/threading/non_thread_safe.h" |
@@ -89,6 +90,13 @@ 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 should be set at once, if this |
+ // isn't sufficient in the future, this chould be expanded into an observer |
+ // API. |
+ void RegisterOnNextSuccessfulWriteCallback( |
+ const base::Closure& on_next_successful_write); |
+ |
TimeDelta commit_interval() const { |
return commit_interval_; |
} |
@@ -98,6 +106,13 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe { |
} |
private: |
+ // If |result| is true and |on_succesful_write_| is set, invokes |
Bernhard Bauer
2014/04/30 09:31:05
Nit: The member is |on_next_successful_write_| (in
gab
2014/04/30 14:32:53
Done.
|
+ // |on_successful_write_| and then resets it; no-ops otherwise. |
+ void ForwardSuccessfulWrite(bool result); |
+ |
+ // Invoked once and then reset on the next successful write event. |
+ base::Closure on_next_successful_write_; |
+ |
// Path being written to. |
const FilePath path_; |
@@ -113,6 +128,8 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe { |
// Time delta after which scheduled data will be written to disk. |
TimeDelta commit_interval_; |
+ WeakPtrFactory<ImportantFileWriter> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); |
}; |