diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/browser/fileapi/file_system_operation_impl.cc | 33 | ||||
-rw-r--r-- | storage/browser/fileapi/file_system_operation_impl.h | 3 |
2 files changed, 24 insertions, 12 deletions
diff --git a/storage/browser/fileapi/file_system_operation_impl.cc b/storage/browser/fileapi/file_system_operation_impl.cc index 75985f4..25613dd 100644 --- a/storage/browser/fileapi/file_system_operation_impl.cc +++ b/storage/browser/fileapi/file_system_operation_impl.cc @@ -31,6 +31,28 @@ using storage::ScopedFile; namespace storage { +namespace { + +// Takes ownership and destruct on the target thread. +void Destruct(base::File file) {} + +void DidOpenFile( + scoped_refptr<FileSystemContext> context, + base::WeakPtr<FileSystemOperationImpl> operation, + const FileSystemOperationImpl::OpenFileCallback& callback, + base::File file, + const base::Closure& on_close_callback) { + if (!operation) { + context->default_file_task_runner()->PostTask( + FROM_HERE, + base::Bind(&Destruct, base::Passed(&file))); + return; + } + callback.Run(file.Pass(), on_close_callback); +} + +} // namespace + FileSystemOperation* FileSystemOperation::Create( const FileSystemURL& url, FileSystemContext* file_system_context, @@ -449,8 +471,8 @@ void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url, int file_flags) { async_file_util_->CreateOrOpen( operation_context_.Pass(), url, file_flags, - base::Bind(&FileSystemOperationImpl::DidOpenFile, - weak_factory_.GetWeakPtr(), callback)); + base::Bind(&DidOpenFile, + file_system_context_, weak_factory_.GetWeakPtr(), callback)); } void FileSystemOperationImpl::DidEnsureFileExistsExclusive( @@ -542,13 +564,6 @@ void FileSystemOperationImpl::DidWrite( cancel_callback.Run(base::File::FILE_OK); } -void FileSystemOperationImpl::DidOpenFile( - const OpenFileCallback& callback, - base::File file, - const base::Closure& on_close_callback) { - callback.Run(file.Pass(), on_close_callback); -} - bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { if (pending_operation_ != kOperationNone) return false; diff --git a/storage/browser/fileapi/file_system_operation_impl.h b/storage/browser/fileapi/file_system_operation_impl.h index 05dd76d..add6b7c 100644 --- a/storage/browser/fileapi/file_system_operation_impl.h +++ b/storage/browser/fileapi/file_system_operation_impl.h @@ -175,9 +175,6 @@ class STORAGE_EXPORT FileSystemOperationImpl base::File::Error rv, int64 bytes, FileWriterDelegate::WriteProgressStatus write_status); - void DidOpenFile(const OpenFileCallback& callback, - base::File file, - const base::Closure& on_close_callback); // Used only for internal assertions. // Returns false if there's another inflight pending operation. |