| 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 ErrorBehavior error_behavior, |
| 91 const CopyProgressCallback& progress_callback, | 92 const CopyProgressCallback& progress_callback, |
| 92 const StatusCallback& callback) { | 93 const StatusCallback& callback) { |
| 93 DCHECK(SetPendingOperationType(kOperationCopy)); | 94 DCHECK(SetPendingOperationType(kOperationCopy)); |
| 94 DCHECK(!recursive_operation_delegate_); | 95 DCHECK(!recursive_operation_delegate_); |
| 95 | 96 |
| 96 // TODO(hidehiko): Support |progress_callback|. (crbug.com/278038). | 97 recursive_operation_delegate_.reset(new CopyOrMoveOperationDelegate( |
| 97 recursive_operation_delegate_.reset( | 98 file_system_context(), src_url, dest_url, |
| 98 new CopyOrMoveOperationDelegate( | 99 CopyOrMoveOperationDelegate::OPERATION_COPY, option, error_behavior, |
| 99 file_system_context(), | 100 progress_callback, |
| 100 src_url, dest_url, | 101 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
| 101 CopyOrMoveOperationDelegate::OPERATION_COPY, | 102 weak_factory_.GetWeakPtr(), callback))); |
| 102 option, | |
| 103 progress_callback, | |
| 104 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | |
| 105 weak_factory_.GetWeakPtr(), callback))); | |
| 106 recursive_operation_delegate_->RunRecursively(); | 103 recursive_operation_delegate_->RunRecursively(); |
| 107 } | 104 } |
| 108 | 105 |
| 109 void FileSystemOperationImpl::Move(const FileSystemURL& src_url, | 106 void FileSystemOperationImpl::Move(const FileSystemURL& src_url, |
| 110 const FileSystemURL& dest_url, | 107 const FileSystemURL& dest_url, |
| 111 CopyOrMoveOption option, | 108 CopyOrMoveOption option, |
| 112 const StatusCallback& callback) { | 109 const StatusCallback& callback) { |
| 113 DCHECK(SetPendingOperationType(kOperationMove)); | 110 DCHECK(SetPendingOperationType(kOperationMove)); |
| 114 DCHECK(!recursive_operation_delegate_); | 111 DCHECK(!recursive_operation_delegate_); |
| 115 recursive_operation_delegate_.reset( | 112 recursive_operation_delegate_.reset(new CopyOrMoveOperationDelegate( |
| 116 new CopyOrMoveOperationDelegate( | 113 file_system_context(), src_url, dest_url, |
| 117 file_system_context(), | 114 CopyOrMoveOperationDelegate::OPERATION_MOVE, option, |
| 118 src_url, dest_url, | 115 ERROR_BEHAVIOR_TERMINATE, FileSystemOperation::CopyProgressCallback(), |
| 119 CopyOrMoveOperationDelegate::OPERATION_MOVE, | 116 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
| 120 option, | 117 weak_factory_.GetWeakPtr(), callback))); |
| 121 FileSystemOperation::CopyProgressCallback(), | |
| 122 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | |
| 123 weak_factory_.GetWeakPtr(), callback))); | |
| 124 recursive_operation_delegate_->RunRecursively(); | 118 recursive_operation_delegate_->RunRecursively(); |
| 125 } | 119 } |
| 126 | 120 |
| 127 void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url, | 121 void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url, |
| 128 const StatusCallback& callback) { | 122 const StatusCallback& callback) { |
| 129 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); | 123 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); |
| 130 async_file_util_->GetFileInfo( | 124 async_file_util_->GetFileInfo( |
| 131 operation_context_.Pass(), url, | 125 operation_context_.Pass(), url, |
| 132 base::Bind(&FileSystemOperationImpl::DidDirectoryExists, | 126 base::Bind(&FileSystemOperationImpl::DidDirectoryExists, |
| 133 weak_factory_.GetWeakPtr(), callback)); | 127 weak_factory_.GetWeakPtr(), callback)); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 555 } |
| 562 | 556 |
| 563 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { | 557 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { |
| 564 if (pending_operation_ != kOperationNone) | 558 if (pending_operation_ != kOperationNone) |
| 565 return false; | 559 return false; |
| 566 pending_operation_ = type; | 560 pending_operation_ = type; |
| 567 return true; | 561 return true; |
| 568 } | 562 } |
| 569 | 563 |
| 570 } // namespace storage | 564 } // namespace storage |
| OLD | NEW |