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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const StatusCallback& callback) { | 59 const StatusCallback& callback) { |
60 DCHECK(SetPendingOperationType(kOperationCreateDirectory)); | 60 DCHECK(SetPendingOperationType(kOperationCreateDirectory)); |
61 GetUsageAndQuotaThenRunTask( | 61 GetUsageAndQuotaThenRunTask( |
62 url, | 62 url, |
63 base::Bind(&FileSystemOperationImpl::DoCreateDirectory, | 63 base::Bind(&FileSystemOperationImpl::DoCreateDirectory, |
64 weak_factory_.GetWeakPtr(), url, callback, | 64 weak_factory_.GetWeakPtr(), url, callback, |
65 exclusive, recursive), | 65 exclusive, recursive), |
66 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 66 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
67 } | 67 } |
68 | 68 |
69 void FileSystemOperationImpl::Copy(const FileSystemURL& src_url, | 69 void FileSystemOperationImpl::Copy( |
70 const FileSystemURL& dest_url, | 70 const FileSystemURL& src_url, |
71 const StatusCallback& callback) { | 71 const FileSystemURL& dest_url, |
| 72 const CopyProgressCallback& progress_callback, |
| 73 const StatusCallback& callback) { |
72 DCHECK(SetPendingOperationType(kOperationCopy)); | 74 DCHECK(SetPendingOperationType(kOperationCopy)); |
73 DCHECK(!recursive_operation_delegate_); | 75 DCHECK(!recursive_operation_delegate_); |
| 76 |
| 77 // TODO(hidehiko): Support |progress_callback|. (crbug.com/278038). |
74 recursive_operation_delegate_.reset( | 78 recursive_operation_delegate_.reset( |
75 new CopyOrMoveOperationDelegate( | 79 new CopyOrMoveOperationDelegate( |
76 file_system_context(), | 80 file_system_context(), |
77 src_url, dest_url, | 81 src_url, dest_url, |
78 CopyOrMoveOperationDelegate::OPERATION_COPY, | 82 CopyOrMoveOperationDelegate::OPERATION_COPY, |
79 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 83 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
80 weak_factory_.GetWeakPtr(), callback))); | 84 weak_factory_.GetWeakPtr(), callback))); |
81 recursive_operation_delegate_->RunRecursively(); | 85 recursive_operation_delegate_->RunRecursively(); |
82 } | 86 } |
83 | 87 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 DCHECK(SetPendingOperationType(kOperationRemove)); | 272 DCHECK(SetPendingOperationType(kOperationRemove)); |
269 async_file_util_->DeleteDirectory( | 273 async_file_util_->DeleteDirectory( |
270 operation_context_.Pass(), url, | 274 operation_context_.Pass(), url, |
271 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 275 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
272 weak_factory_.GetWeakPtr(), callback)); | 276 weak_factory_.GetWeakPtr(), callback)); |
273 } | 277 } |
274 | 278 |
275 void FileSystemOperationImpl::CopyFileLocal( | 279 void FileSystemOperationImpl::CopyFileLocal( |
276 const FileSystemURL& src_url, | 280 const FileSystemURL& src_url, |
277 const FileSystemURL& dest_url, | 281 const FileSystemURL& dest_url, |
| 282 const CopyFileProgressCallback& progress_callback, |
278 const StatusCallback& callback) { | 283 const StatusCallback& callback) { |
279 DCHECK(SetPendingOperationType(kOperationCopy)); | 284 DCHECK(SetPendingOperationType(kOperationCopy)); |
280 DCHECK(src_url.IsInSameFileSystem(dest_url)); | 285 DCHECK(src_url.IsInSameFileSystem(dest_url)); |
| 286 |
| 287 // TODO(hidehiko): Support progress_callback. |
281 GetUsageAndQuotaThenRunTask( | 288 GetUsageAndQuotaThenRunTask( |
282 dest_url, | 289 dest_url, |
283 base::Bind(&FileSystemOperationImpl::DoCopyFileLocal, | 290 base::Bind(&FileSystemOperationImpl::DoCopyFileLocal, |
284 weak_factory_.GetWeakPtr(), src_url, dest_url, callback), | 291 weak_factory_.GetWeakPtr(), src_url, dest_url, callback), |
285 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 292 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
286 } | 293 } |
287 | 294 |
288 void FileSystemOperationImpl::MoveFileLocal( | 295 void FileSystemOperationImpl::MoveFileLocal( |
289 const FileSystemURL& src_url, | 296 const FileSystemURL& src_url, |
290 const FileSystemURL& dest_url, | 297 const FileSystemURL& dest_url, |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 547 } |
541 | 548 |
542 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { | 549 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { |
543 if (pending_operation_ != kOperationNone) | 550 if (pending_operation_ != kOperationNone) |
544 return false; | 551 return false; |
545 pending_operation_ = type; | 552 pending_operation_ = type; |
546 return true; | 553 return true; |
547 } | 554 } |
548 | 555 |
549 } // namespace fileapi | 556 } // namespace fileapi |
OLD | NEW |