| 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 "webkit/browser/fileapi/file_system_operation_impl.h" | 5 #include "webkit/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const StatusCallback& callback) { | 67 const StatusCallback& callback) { |
| 68 DCHECK(SetPendingOperationType(kOperationCreateDirectory)); | 68 DCHECK(SetPendingOperationType(kOperationCreateDirectory)); |
| 69 GetUsageAndQuotaThenRunTask( | 69 GetUsageAndQuotaThenRunTask( |
| 70 url, | 70 url, |
| 71 base::Bind(&FileSystemOperationImpl::DoCreateDirectory, | 71 base::Bind(&FileSystemOperationImpl::DoCreateDirectory, |
| 72 weak_factory_.GetWeakPtr(), url, callback, | 72 weak_factory_.GetWeakPtr(), url, callback, |
| 73 exclusive, recursive), | 73 exclusive, recursive), |
| 74 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 74 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void FileSystemOperationImpl::Copy(const FileSystemURL& src_url, | 77 void FileSystemOperationImpl::Copy( |
| 78 const FileSystemURL& dest_url, | 78 const FileSystemURL& src_url, |
| 79 const StatusCallback& callback) { | 79 const FileSystemURL& dest_url, |
| 80 const CopyProgressCallback& progress_callback, |
| 81 const StatusCallback& callback) { |
| 80 DCHECK(SetPendingOperationType(kOperationCopy)); | 82 DCHECK(SetPendingOperationType(kOperationCopy)); |
| 81 DCHECK(!recursive_operation_delegate_); | 83 DCHECK(!recursive_operation_delegate_); |
| 84 |
| 85 // TODO(hidehiko): Support |progress_callback|. (crbug.com/278038). |
| 82 recursive_operation_delegate_.reset( | 86 recursive_operation_delegate_.reset( |
| 83 new CopyOrMoveOperationDelegate( | 87 new CopyOrMoveOperationDelegate( |
| 84 file_system_context(), | 88 file_system_context(), |
| 85 src_url, dest_url, | 89 src_url, dest_url, |
| 86 CopyOrMoveOperationDelegate::OPERATION_COPY, | 90 CopyOrMoveOperationDelegate::OPERATION_COPY, |
| 87 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 91 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
| 88 weak_factory_.GetWeakPtr(), callback))); | 92 weak_factory_.GetWeakPtr(), callback))); |
| 89 recursive_operation_delegate_->RunRecursively(); | 93 recursive_operation_delegate_->RunRecursively(); |
| 90 } | 94 } |
| 91 | 95 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 DCHECK(SetPendingOperationType(kOperationRemove)); | 280 DCHECK(SetPendingOperationType(kOperationRemove)); |
| 277 async_file_util_->DeleteDirectory( | 281 async_file_util_->DeleteDirectory( |
| 278 operation_context_.Pass(), url, | 282 operation_context_.Pass(), url, |
| 279 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 283 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
| 280 weak_factory_.GetWeakPtr(), callback)); | 284 weak_factory_.GetWeakPtr(), callback)); |
| 281 } | 285 } |
| 282 | 286 |
| 283 void FileSystemOperationImpl::CopyFileLocal( | 287 void FileSystemOperationImpl::CopyFileLocal( |
| 284 const FileSystemURL& src_url, | 288 const FileSystemURL& src_url, |
| 285 const FileSystemURL& dest_url, | 289 const FileSystemURL& dest_url, |
| 290 const CopyFileProgressCallback& progress_callback, |
| 286 const StatusCallback& callback) { | 291 const StatusCallback& callback) { |
| 287 DCHECK(SetPendingOperationType(kOperationCopy)); | 292 DCHECK(SetPendingOperationType(kOperationCopy)); |
| 288 DCHECK(src_url.IsInSameFileSystem(dest_url)); | 293 DCHECK(src_url.IsInSameFileSystem(dest_url)); |
| 294 |
| 295 // TODO(hidehiko): Support progress_callback. |
| 289 GetUsageAndQuotaThenRunTask( | 296 GetUsageAndQuotaThenRunTask( |
| 290 dest_url, | 297 dest_url, |
| 291 base::Bind(&FileSystemOperationImpl::DoCopyFileLocal, | 298 base::Bind(&FileSystemOperationImpl::DoCopyFileLocal, |
| 292 weak_factory_.GetWeakPtr(), src_url, dest_url, callback), | 299 weak_factory_.GetWeakPtr(), src_url, dest_url, callback), |
| 293 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 300 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 294 } | 301 } |
| 295 | 302 |
| 296 void FileSystemOperationImpl::MoveFileLocal( | 303 void FileSystemOperationImpl::MoveFileLocal( |
| 297 const FileSystemURL& src_url, | 304 const FileSystemURL& src_url, |
| 298 const FileSystemURL& dest_url, | 305 const FileSystemURL& dest_url, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 539 } |
| 533 | 540 |
| 534 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { | 541 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { |
| 535 if (pending_operation_ != kOperationNone) | 542 if (pending_operation_ != kOperationNone) |
| 536 return false; | 543 return false; |
| 537 pending_operation_ = type; | 544 pending_operation_ = type; |
| 538 return true; | 545 return true; |
| 539 } | 546 } |
| 540 | 547 |
| 541 } // namespace fileapi | 548 } // namespace fileapi |
| OLD | NEW |