diff options
author | kinuko <kinuko@chromium.org> | 2014-12-15 19:03:54 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-16 03:04:16 +0000 |
commit | 5c0e45fae145803dec7d4b956b9abb3a1d304dbd (patch) | |
tree | 4cefc4ac36c4fcb9fc8180f83446df1b55f8cff1 /storage | |
parent | 1edeff8c6a93bd7a0158f8a0e8ef83db411e3363 (diff) | |
download | chromium_src-5c0e45fae145803dec7d4b956b9abb3a1d304dbd.zip chromium_src-5c0e45fae145803dec7d4b956b9abb3a1d304dbd.tar.gz chromium_src-5c0e45fae145803dec7d4b956b9abb3a1d304dbd.tar.bz2 |
Cleanup base::File on FILE thread even when FileSystemOperationRunner is shut down
BUG=415401
TEST=MultiThreadFileSystemOperationRunnerTest.OpenAndShutdown
Review URL: https://codereview.chromium.org/798333002
Cr-Commit-Position: refs/heads/master@{#308516}
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. |