From a8ea1b0a6ee05bbbef78b0b7275c1177e60efca3 Mon Sep 17 00:00:00 2001 From: mtomasz Date: Tue, 9 Dec 2014 02:54:36 -0800 Subject: Remove FileSystemContext::ShouldFlushOnWriteCompletion. FileSystemContext::ShouldFlushOnWriteCompletion was used only for writing. For streamed copying or moving, storage::CopySyncOption was used. Even if both writing and copying is done via the same FileStreamWriter, the decision about flushing it was done in two different ways. This patch removes ShouldFlushOnWriteCompletion, as decision about flushing should be the same for copying and writing, as both are writing operations and data may be lost. For sandboxed file systems storage::CopySyncOption::copy_sync_option() is COPY_SYNC_OPTION_NO_SYNC, so there is no change. They will not be flushed. For non-sandboxed file systems, they will be flushed consistently for write and streamed copy/move, depending on storage::CopySyncOption. The storage::CopySyncOption enum is going to be renamed to storage:: WriteSyncOption in an upcoming patch. TEST=Partially by file_system_operation_impl_write_unittest.cc. BUG=440293 Review URL: https://codereview.chromium.org/785193002 Cr-Commit-Position: refs/heads/master@{#307445} --- storage/browser/fileapi/file_stream_writer.h | 5 ++--- storage/browser/fileapi/file_system_context.cc | 14 -------------- storage/browser/fileapi/file_system_context.h | 4 ---- storage/browser/fileapi/file_system_operation_runner.cc | 2 +- 4 files changed, 3 insertions(+), 22 deletions(-) (limited to 'storage') diff --git a/storage/browser/fileapi/file_stream_writer.h b/storage/browser/fileapi/file_stream_writer.h index c077100..e00f9dc 100644 --- a/storage/browser/fileapi/file_stream_writer.h +++ b/storage/browser/fileapi/file_stream_writer.h @@ -46,9 +46,8 @@ class FileStreamWriter { // callback will be run on the thread where Write() was called when the write // has completed. // - // After the last write, Flush() must be called unless the flushing on - // completion is explicitly disabled for the file system type, the writer is - // created for. See FileSystemContext::ShouldFlushOnWriteCompletion(). + // After the last write, Flush() must be called if the file system written to + // was registered with the COPY_SYNC_OPTION_SYNC mount option. // // This errors out (either synchronously or via callback) with: // net::ERR_FILE_NOT_FOUND: When the target file is not found. diff --git a/storage/browser/fileapi/file_system_context.cc b/storage/browser/fileapi/file_system_context.cc index c6ef9fd..4b300ef 100644 --- a/storage/browser/fileapi/file_system_context.cc +++ b/storage/browser/fileapi/file_system_context.cc @@ -488,20 +488,6 @@ bool FileSystemContext::CanServeURLRequest(const FileSystemURL& url) const { return !is_incognito_ || !FileSystemContext::IsSandboxFileSystem(url.type()); } -bool FileSystemContext::ShouldFlushOnWriteCompletion( - FileSystemType type) const { - if (IsSandboxFileSystem(type)) { - // Disable Flush() for each write operation on SandboxFileSystems since it - // hurts the performance, assuming the FileSystems are stored in a local - // disk, we don't need to keep calling fsync() for it. - // On the other hand, other FileSystems that may stored on a removable media - // should be Flush()ed as soon as a write operation is completed, so that - // written data is saved over sudden media removal. - return false; - } - return true; -} - void FileSystemContext::OpenPluginPrivateFileSystem( const GURL& origin_url, FileSystemType type, diff --git a/storage/browser/fileapi/file_system_context.h b/storage/browser/fileapi/file_system_context.h index ca98271..53fef62 100644 --- a/storage/browser/fileapi/file_system_context.h +++ b/storage/browser/fileapi/file_system_context.h @@ -299,10 +299,6 @@ class STORAGE_EXPORT FileSystemContext // (E.g. this returns false if the context is created for incognito mode) bool CanServeURLRequest(const FileSystemURL& url) const; - // Returns true if a file in the file system should be flushed for each write - // completion. - bool ShouldFlushOnWriteCompletion(FileSystemType type) const; - // This must be used to open 'plugin private' filesystem. // See "plugin_private_file_system_backend.h" for more details. void OpenPluginPrivateFileSystem( diff --git a/storage/browser/fileapi/file_system_operation_runner.cc b/storage/browser/fileapi/file_system_operation_runner.cc index 018961b..c11a4b2 100644 --- a/storage/browser/fileapi/file_system_operation_runner.cc +++ b/storage/browser/fileapi/file_system_operation_runner.cc @@ -261,7 +261,7 @@ OperationID FileSystemOperationRunner::Write( } FileWriterDelegate::FlushPolicy flush_policy = - file_system_context_->ShouldFlushOnWriteCompletion(url.type()) + url.mount_option().copy_sync_option() == COPY_SYNC_OPTION_SYNC ? FileWriterDelegate::FLUSH_ON_COMPLETION : FileWriterDelegate::NO_FLUSH_ON_COMPLETION; scoped_ptr writer_delegate( -- cgit v1.1