| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "storage/browser/fileapi/file_system_operation_impl.h" | 5 #include "storage/browser/fileapi/file_system_operation_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 base::Bind(&FileSystemOperationImpl::DoCreateDirectory, | 81 base::Bind(&FileSystemOperationImpl::DoCreateDirectory, |
| 82 weak_factory_.GetWeakPtr(), url, callback, | 82 weak_factory_.GetWeakPtr(), url, callback, |
| 83 exclusive, recursive), | 83 exclusive, recursive), |
| 84 base::Bind(callback, base::File::FILE_ERROR_FAILED)); | 84 base::Bind(callback, base::File::FILE_ERROR_FAILED)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void FileSystemOperationImpl::Copy( | 87 void FileSystemOperationImpl::Copy( |
| 88 const FileSystemURL& src_url, | 88 const FileSystemURL& src_url, |
| 89 const FileSystemURL& dest_url, | 89 const FileSystemURL& dest_url, |
| 90 CopyOrMoveOption option, | 90 CopyOrMoveOption option, |
| 91 const bool continue_with_error, |
| 92 const CopyOrMoveErrorCallback& error_callback, |
| 91 const CopyProgressCallback& progress_callback, | 93 const CopyProgressCallback& progress_callback, |
| 92 const StatusCallback& callback) { | 94 const StatusCallback& callback) { |
| 93 DCHECK(SetPendingOperationType(kOperationCopy)); | 95 DCHECK(SetPendingOperationType(kOperationCopy)); |
| 94 DCHECK(!recursive_operation_delegate_); | 96 DCHECK(!recursive_operation_delegate_); |
| 95 | 97 |
| 96 // TODO(hidehiko): Support |progress_callback|. (crbug.com/278038). | 98 recursive_operation_delegate_.reset(new CopyOrMoveOperationDelegate( |
| 97 recursive_operation_delegate_.reset( | 99 file_system_context(), src_url, dest_url, |
| 98 new CopyOrMoveOperationDelegate( | 100 CopyOrMoveOperationDelegate::OPERATION_COPY, option, continue_with_error, |
| 99 file_system_context(), | 101 error_callback, progress_callback, |
| 100 src_url, dest_url, | 102 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
| 101 CopyOrMoveOperationDelegate::OPERATION_COPY, | 103 weak_factory_.GetWeakPtr(), callback))); |
| 102 option, | |
| 103 progress_callback, | |
| 104 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | |
| 105 weak_factory_.GetWeakPtr(), callback))); | |
| 106 recursive_operation_delegate_->RunRecursively(); | 104 recursive_operation_delegate_->RunRecursively(); |
| 107 } | 105 } |
| 108 | 106 |
| 109 void FileSystemOperationImpl::Move(const FileSystemURL& src_url, | 107 void FileSystemOperationImpl::Move(const FileSystemURL& src_url, |
| 110 const FileSystemURL& dest_url, | 108 const FileSystemURL& dest_url, |
| 111 CopyOrMoveOption option, | 109 CopyOrMoveOption option, |
| 112 const StatusCallback& callback) { | 110 const StatusCallback& callback) { |
| 113 DCHECK(SetPendingOperationType(kOperationMove)); | 111 DCHECK(SetPendingOperationType(kOperationMove)); |
| 114 DCHECK(!recursive_operation_delegate_); | 112 DCHECK(!recursive_operation_delegate_); |
| 115 recursive_operation_delegate_.reset( | 113 recursive_operation_delegate_.reset(new CopyOrMoveOperationDelegate( |
| 116 new CopyOrMoveOperationDelegate( | 114 file_system_context(), src_url, dest_url, |
| 117 file_system_context(), | 115 CopyOrMoveOperationDelegate::OPERATION_MOVE, option, false, |
| 118 src_url, dest_url, | 116 CopyOrMoveErrorCallback(), FileSystemOperation::CopyProgressCallback(), |
| 119 CopyOrMoveOperationDelegate::OPERATION_MOVE, | 117 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
| 120 option, | 118 weak_factory_.GetWeakPtr(), callback))); |
| 121 FileSystemOperation::CopyProgressCallback(), | |
| 122 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | |
| 123 weak_factory_.GetWeakPtr(), callback))); | |
| 124 recursive_operation_delegate_->RunRecursively(); | 119 recursive_operation_delegate_->RunRecursively(); |
| 125 } | 120 } |
| 126 | 121 |
| 127 void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url, | 122 void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url, |
| 128 const StatusCallback& callback) { | 123 const StatusCallback& callback) { |
| 129 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); | 124 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); |
| 130 async_file_util_->GetFileInfo( | 125 async_file_util_->GetFileInfo( |
| 131 operation_context_.Pass(), url, | 126 operation_context_.Pass(), url, |
| 132 base::Bind(&FileSystemOperationImpl::DidDirectoryExists, | 127 base::Bind(&FileSystemOperationImpl::DidDirectoryExists, |
| 133 weak_factory_.GetWeakPtr(), callback)); | 128 weak_factory_.GetWeakPtr(), callback)); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 556 } |
| 562 | 557 |
| 563 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { | 558 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { |
| 564 if (pending_operation_ != kOperationNone) | 559 if (pending_operation_ != kOperationNone) |
| 565 return false; | 560 return false; |
| 566 pending_operation_ = type; | 561 pending_operation_ = type; |
| 567 return true; | 562 return true; |
| 568 } | 563 } |
| 569 | 564 |
| 570 } // namespace storage | 565 } // namespace storage |
| OLD | NEW |