From a95ce07699b8ce79df8b59e36fe53b345a5921b2 Mon Sep 17 00:00:00 2001 From: "kinaba@chromium.org" Date: Mon, 1 Oct 2012 05:54:26 +0000 Subject: Flush at the end of local file writing in FileWriter API. This CL ensures the written content is flushed physically before fileWriter.write() invokes the "onwriteend" event, for native local files. Remote files (Google Drive files in Chrome OS) nor FileSystem API files (in PERSISTENT or TEMPORARY storage) aren't affected. The summary of the changes: * Call Flush() before the final callback. (webkit/fileapi/file_writer_delegate.cc) * Delegate Flush() to net::FileStream::Flush (webkit/fileapi/local_file_stream_writer.cc) * No-op implementation for Flush(). (webkit/fileapi/sanbox_file_stream_writer.cc) (webkit/chromeos/fileapi/remote_file_stream_writer.cc) * Implementation of asynchronous Flush. (net/base/file_stream_{posix,win}.cc) * Other files are just for reflecting the rename Flush -> FlushSync. BUG=144790 R=willchan@chromium.org,kinuko@chromium.org,benjhayden@chromium.org TBR=marja@chromium.org TEST=out/Debug/browser_tests --gtest_filter='*FileSystemApi*' TEST=./webkit/tools/layout_tests/run_webkit_tests.sh fast/filesystem TEST=Manual steps reported in the issue. Review URL: https://codereview.chromium.org/10986045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159454 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/fileapi/file_stream_writer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'webkit/fileapi/file_stream_writer.h') diff --git a/webkit/fileapi/file_stream_writer.h b/webkit/fileapi/file_stream_writer.h index 967d501..f3f6398 100644 --- a/webkit/fileapi/file_stream_writer.h +++ b/webkit/fileapi/file_stream_writer.h @@ -55,6 +55,16 @@ class FILEAPI_EXPORT_PRIVATE FileStreamWriter { // operation is dismissed immediately when Cancel() is called, and thus // will never be called. virtual int Cancel(const net::CompletionCallback& callback) = 0; + + // Flushes the data written so far. + // + // If the flush finished synchronously, it return net::OK. If the flush could + // not be performed, it returns an error code. Otherwise, net::ERR_IO_PENDING + // is returned, and the callback will be run on the thread where Flush() was + // called when the flush has completed. + // + // It is invalid to call Flush while there is an in-flight async operation. + virtual int Flush(const net::CompletionCallback& callback) = 0; }; } // namespace fileapi -- cgit v1.1