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

Unified Diff: webkit/fileapi/local_file_stream_writer.cc

Issue 11030044: Merge 159454 - Flush at the end of local file writing in FileWriter API. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 2 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
===================================================================
--- webkit/fileapi/local_file_stream_writer.cc (revision 160294)
+++ webkit/fileapi/local_file_stream_writer.cc (working copy)
@@ -64,6 +64,21 @@
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 @@
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