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

Unified Diff: webkit/fileapi/local_file_stream_writer.cc

Issue 10986045: Flush at the end of local file writing in FileWriter API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up. Created 8 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 | « webkit/fileapi/local_file_stream_writer.h ('k') | webkit/fileapi/sandbox_file_stream_writer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/local_file_stream_writer.cc
diff --git a/webkit/fileapi/local_file_stream_writer.cc b/webkit/fileapi/local_file_stream_writer.cc
index 95a2a7e691d3fd729e733ed96370f0c884ced7c6..f3679f9e1ca73bdf22349a00154ed0eda1709c1a 100644
--- a/webkit/fileapi/local_file_stream_writer.cc
+++ b/webkit/fileapi/local_file_stream_writer.cc
@@ -64,6 +64,21 @@ int LocalFileStreamWriter::Cancel(const net::CompletionCallback& callback) {
return net::ERR_IO_PENDING;
}
+int LocalFileStreamWriter::Flush(const net::CompletionCallback& callback) {
+ DCHECK(!has_pending_operation_);
+ DCHECK(cancel_callback_.is_null());
+
+ // Write() is not called yet, so there's nothing to flush.
+ if (!stream_impl_.get())
+ return net::OK;
+
+ has_pending_operation_ = true;
+ int result = InitiateFlush(callback);
+ if (result != net::ERR_IO_PENDING)
+ has_pending_operation_ = false;
+ return result;
+}
+
int LocalFileStreamWriter::InitiateOpen(
const net::CompletionCallback& error_callback,
const base::Closure& main_operation) {
@@ -179,6 +194,26 @@ void LocalFileStreamWriter::DidWrite(const net::CompletionCallback& callback,
callback.Run(result);
}
+int LocalFileStreamWriter::InitiateFlush(
+ const net::CompletionCallback& callback) {
+ DCHECK(has_pending_operation_);
+ DCHECK(stream_impl_.get());
+
+ return stream_impl_->Flush(base::Bind(&LocalFileStreamWriter::DidFlush,
+ weak_factory_.GetWeakPtr(),
+ callback));
+}
+
+void LocalFileStreamWriter::DidFlush(const net::CompletionCallback& callback,
+ int result) {
+ DCHECK(has_pending_operation_);
+
+ if (CancelIfRequested())
+ return;
+ has_pending_operation_ = false;
+ callback.Run(result);
+}
+
bool LocalFileStreamWriter::CancelIfRequested() {
DCHECK(has_pending_operation_);
« no previous file with comments | « webkit/fileapi/local_file_stream_writer.h ('k') | webkit/fileapi/sandbox_file_stream_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698