OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/copy_or_move_operation_delegate.h" | 5 #include "storage/browser/fileapi/copy_or_move_operation_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 file_progress_callback_(file_progress_callback), | 384 file_progress_callback_(file_progress_callback), |
385 cancel_requested_(false), | 385 cancel_requested_(false), |
386 weak_factory_(this) {} | 386 weak_factory_(this) {} |
387 | 387 |
388 void Run( | 388 void Run( |
389 const CopyOrMoveOperationDelegate::StatusCallback& callback) override { | 389 const CopyOrMoveOperationDelegate::StatusCallback& callback) override { |
390 // Reader can be created even if the entry does not exist or the entry is | 390 // Reader can be created even if the entry does not exist or the entry is |
391 // a directory. To check errors before destination file creation, | 391 // a directory. To check errors before destination file creation, |
392 // check metadata first. | 392 // check metadata first. |
393 operation_runner_->GetMetadata( | 393 operation_runner_->GetMetadata( |
394 src_url_, | 394 src_url_, FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY | |
| 395 FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED, |
395 base::Bind(&StreamCopyOrMoveImpl::RunAfterGetMetadataForSource, | 396 base::Bind(&StreamCopyOrMoveImpl::RunAfterGetMetadataForSource, |
396 weak_factory_.GetWeakPtr(), callback)); | 397 weak_factory_.GetWeakPtr(), callback)); |
397 } | 398 } |
398 | 399 |
399 void Cancel() override { | 400 void Cancel() override { |
400 cancel_requested_ = true; | 401 cancel_requested_ = true; |
401 if (copy_helper_) | 402 if (copy_helper_) |
402 copy_helper_->Cancel(); | 403 copy_helper_->Cancel(); |
403 } | 404 } |
404 | 405 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 void CopyOrMoveOperationDelegate::PostProcessDirectory( | 878 void CopyOrMoveOperationDelegate::PostProcessDirectory( |
878 const FileSystemURL& src_url, | 879 const FileSystemURL& src_url, |
879 const StatusCallback& callback) { | 880 const StatusCallback& callback) { |
880 if (option_ == FileSystemOperation::OPTION_NONE) { | 881 if (option_ == FileSystemOperation::OPTION_NONE) { |
881 PostProcessDirectoryAfterTouchFile( | 882 PostProcessDirectoryAfterTouchFile( |
882 src_url, callback, base::File::FILE_OK); | 883 src_url, callback, base::File::FILE_OK); |
883 return; | 884 return; |
884 } | 885 } |
885 | 886 |
886 operation_runner()->GetMetadata( | 887 operation_runner()->GetMetadata( |
887 src_url, | 888 src_url, FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED, |
888 base::Bind( | 889 base::Bind( |
889 &CopyOrMoveOperationDelegate::PostProcessDirectoryAfterGetMetadata, | 890 &CopyOrMoveOperationDelegate::PostProcessDirectoryAfterGetMetadata, |
890 weak_factory_.GetWeakPtr(), src_url, callback)); | 891 weak_factory_.GetWeakPtr(), src_url, callback)); |
891 } | 892 } |
892 | 893 |
893 void CopyOrMoveOperationDelegate::OnCancel() { | 894 void CopyOrMoveOperationDelegate::OnCancel() { |
894 // Request to cancel all running Copy/Move file. | 895 // Request to cancel all running Copy/Move file. |
895 for (std::set<CopyOrMoveImpl*>::iterator iter = running_copy_set_.begin(); | 896 for (std::set<CopyOrMoveImpl*>::iterator iter = running_copy_set_.begin(); |
896 iter != running_copy_set_.end(); ++iter) | 897 iter != running_copy_set_.end(); ++iter) |
897 (*iter)->Cancel(); | 898 (*iter)->Cancel(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 base::FilePath relative = dest_root_.virtual_path(); | 1028 base::FilePath relative = dest_root_.virtual_path(); |
1028 src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(), | 1029 src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(), |
1029 &relative); | 1030 &relative); |
1030 return file_system_context()->CreateCrackedFileSystemURL( | 1031 return file_system_context()->CreateCrackedFileSystemURL( |
1031 dest_root_.origin(), | 1032 dest_root_.origin(), |
1032 dest_root_.mount_type(), | 1033 dest_root_.mount_type(), |
1033 relative); | 1034 relative); |
1034 } | 1035 } |
1035 | 1036 |
1036 } // namespace storage | 1037 } // namespace storage |
OLD | NEW |