OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/local_file_system_operation.h" | 5 #include "webkit/browser/fileapi/local_file_system_operation.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/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 operation_context(), url, | 510 operation_context(), url, |
511 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 511 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
512 base::Owned(this), callback)); | 512 base::Owned(this), callback)); |
513 } | 513 } |
514 | 514 |
515 void LocalFileSystemOperation::CopyFileLocal( | 515 void LocalFileSystemOperation::CopyFileLocal( |
516 const FileSystemURL& src_url, | 516 const FileSystemURL& src_url, |
517 const FileSystemURL& dest_url, | 517 const FileSystemURL& dest_url, |
518 const StatusCallback& callback) { | 518 const StatusCallback& callback) { |
519 DCHECK(SetPendingOperationType(kOperationCopy)); | 519 DCHECK(SetPendingOperationType(kOperationCopy)); |
520 DCHECK(AreSameFileSystem(src_url, dest_url)); | 520 DCHECK(src_url.IsInSameFileSystem(dest_url)); |
521 | 521 |
522 base::PlatformFileError result = SetUp(src_url, OPERATION_MODE_READ); | 522 base::PlatformFileError result = SetUp(src_url, OPERATION_MODE_READ); |
523 if (result == base::PLATFORM_FILE_OK) | 523 if (result == base::PLATFORM_FILE_OK) |
524 result = SetUp(dest_url, OPERATION_MODE_WRITE); | 524 result = SetUp(dest_url, OPERATION_MODE_WRITE); |
525 if (result != base::PLATFORM_FILE_OK) { | 525 if (result != base::PLATFORM_FILE_OK) { |
526 callback.Run(result); | 526 callback.Run(result); |
527 delete this; | 527 delete this; |
528 return; | 528 return; |
529 } | 529 } |
530 | 530 |
531 GetUsageAndQuotaThenRunTask( | 531 GetUsageAndQuotaThenRunTask( |
532 dest_url, | 532 dest_url, |
533 base::Bind(&LocalFileSystemOperation::DoCopyFileLocal, | 533 base::Bind(&LocalFileSystemOperation::DoCopyFileLocal, |
534 base::Unretained(this), src_url, dest_url, callback), | 534 base::Unretained(this), src_url, dest_url, callback), |
535 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 535 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
536 } | 536 } |
537 | 537 |
538 void LocalFileSystemOperation::MoveFileLocal( | 538 void LocalFileSystemOperation::MoveFileLocal( |
539 const FileSystemURL& src_url, | 539 const FileSystemURL& src_url, |
540 const FileSystemURL& dest_url, | 540 const FileSystemURL& dest_url, |
541 const StatusCallback& callback) { | 541 const StatusCallback& callback) { |
542 DCHECK(SetPendingOperationType(kOperationMove)); | 542 DCHECK(SetPendingOperationType(kOperationMove)); |
543 DCHECK(AreSameFileSystem(src_url, dest_url)); | 543 DCHECK(src_url.IsInSameFileSystem(dest_url)); |
544 | 544 |
545 base::PlatformFileError result = SetUp(src_url, OPERATION_MODE_WRITE); | 545 base::PlatformFileError result = SetUp(src_url, OPERATION_MODE_WRITE); |
546 if (result == base::PLATFORM_FILE_OK) | 546 if (result == base::PLATFORM_FILE_OK) |
547 result = SetUp(dest_url, OPERATION_MODE_WRITE); | 547 result = SetUp(dest_url, OPERATION_MODE_WRITE); |
548 if (result != base::PLATFORM_FILE_OK) { | 548 if (result != base::PLATFORM_FILE_OK) { |
549 callback.Run(result); | 549 callback.Run(result); |
550 delete this; | 550 delete this; |
551 return; | 551 return; |
552 } | 552 } |
553 | 553 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 } | 871 } |
872 | 872 |
873 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 873 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
874 if (pending_operation_ != kOperationNone) | 874 if (pending_operation_ != kOperationNone) |
875 return false; | 875 return false; |
876 pending_operation_ = type; | 876 pending_operation_ = type; |
877 return true; | 877 return true; |
878 } | 878 } |
879 | 879 |
880 } // namespace fileapi | 880 } // namespace fileapi |
OLD | NEW |