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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 ScopedThreadStopper thread_stopper(&file_thread); | 728 ScopedThreadStopper thread_stopper(&file_thread); |
729 ASSERT_TRUE(thread_stopper.is_valid()); | 729 ASSERT_TRUE(thread_stopper.is_valid()); |
730 | 730 |
731 scoped_refptr<base::MessageLoopProxy> task_runner = | 731 scoped_refptr<base::MessageLoopProxy> task_runner = |
732 file_thread.message_loop_proxy(); | 732 file_thread.message_loop_proxy(); |
733 | 733 |
734 scoped_ptr<storage::FileStreamReader> reader( | 734 scoped_ptr<storage::FileStreamReader> reader( |
735 storage::FileStreamReader::CreateForLocalFile( | 735 storage::FileStreamReader::CreateForLocalFile( |
736 task_runner.get(), source_path, 0, base::Time())); | 736 task_runner.get(), source_path, 0, base::Time())); |
737 | 737 |
738 scoped_ptr<FileStreamWriter> writer(FileStreamWriter::CreateForLocalFile( | 738 { |
739 task_runner.get(), dest_path, 0, FileStreamWriter::CREATE_NEW_FILE)); | 739 base::File file(dest_path, |
740 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | |
741 EXPECT_TRUE(file.created()); | |
michaeln
2015/03/03 00:02:51
Ah, so there were some uses of the CREATE_NEW_FILE
cmumford
2015/03/03 22:26:09
Done.
| |
742 } | |
743 scoped_ptr<FileStreamWriter> writer( | |
744 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); | |
740 | 745 |
741 std::vector<int64> progress; | 746 std::vector<int64> progress; |
742 CopyOrMoveOperationDelegate::StreamCopyHelper helper( | 747 CopyOrMoveOperationDelegate::StreamCopyHelper helper( |
743 reader.Pass(), writer.Pass(), | 748 reader.Pass(), writer.Pass(), |
744 storage::FlushPolicy::NO_FLUSH_ON_COMPLETION, | 749 storage::FlushPolicy::NO_FLUSH_ON_COMPLETION, |
745 10, // buffer size | 750 10, // buffer size |
746 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), | 751 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), |
747 base::TimeDelta()); // For testing, we need all the progress. | 752 base::TimeDelta()); // For testing, we need all the progress. |
748 | 753 |
749 base::File::Error error = base::File::FILE_ERROR_FAILED; | 754 base::File::Error error = base::File::FILE_ERROR_FAILED; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
784 ScopedThreadStopper thread_stopper(&file_thread); | 789 ScopedThreadStopper thread_stopper(&file_thread); |
785 ASSERT_TRUE(thread_stopper.is_valid()); | 790 ASSERT_TRUE(thread_stopper.is_valid()); |
786 | 791 |
787 scoped_refptr<base::MessageLoopProxy> task_runner = | 792 scoped_refptr<base::MessageLoopProxy> task_runner = |
788 file_thread.message_loop_proxy(); | 793 file_thread.message_loop_proxy(); |
789 | 794 |
790 scoped_ptr<storage::FileStreamReader> reader( | 795 scoped_ptr<storage::FileStreamReader> reader( |
791 storage::FileStreamReader::CreateForLocalFile( | 796 storage::FileStreamReader::CreateForLocalFile( |
792 task_runner.get(), source_path, 0, base::Time())); | 797 task_runner.get(), source_path, 0, base::Time())); |
793 | 798 |
794 scoped_ptr<FileStreamWriter> writer(FileStreamWriter::CreateForLocalFile( | 799 { |
795 task_runner.get(), dest_path, 0, FileStreamWriter::CREATE_NEW_FILE)); | 800 base::File file(dest_path, |
801 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | |
802 EXPECT_TRUE(file.created()); | |
803 } | |
804 scoped_ptr<FileStreamWriter> writer( | |
805 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); | |
796 | 806 |
797 std::vector<int64> progress; | 807 std::vector<int64> progress; |
798 CopyOrMoveOperationDelegate::StreamCopyHelper helper( | 808 CopyOrMoveOperationDelegate::StreamCopyHelper helper( |
799 reader.Pass(), writer.Pass(), | 809 reader.Pass(), writer.Pass(), |
800 storage::FlushPolicy::NO_FLUSH_ON_COMPLETION, | 810 storage::FlushPolicy::NO_FLUSH_ON_COMPLETION, |
801 10, // buffer size | 811 10, // buffer size |
802 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), | 812 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), |
803 base::TimeDelta()); // For testing, we need all the progress. | 813 base::TimeDelta()); // For testing, we need all the progress. |
804 | 814 |
805 base::File::Error error = base::File::FILE_ERROR_FAILED; | 815 base::File::Error error = base::File::FILE_ERROR_FAILED; |
(...skipping 29 matching lines...) Expand all Loading... | |
835 ScopedThreadStopper thread_stopper(&file_thread); | 845 ScopedThreadStopper thread_stopper(&file_thread); |
836 ASSERT_TRUE(thread_stopper.is_valid()); | 846 ASSERT_TRUE(thread_stopper.is_valid()); |
837 | 847 |
838 scoped_refptr<base::MessageLoopProxy> task_runner = | 848 scoped_refptr<base::MessageLoopProxy> task_runner = |
839 file_thread.message_loop_proxy(); | 849 file_thread.message_loop_proxy(); |
840 | 850 |
841 scoped_ptr<storage::FileStreamReader> reader( | 851 scoped_ptr<storage::FileStreamReader> reader( |
842 storage::FileStreamReader::CreateForLocalFile( | 852 storage::FileStreamReader::CreateForLocalFile( |
843 task_runner.get(), source_path, 0, base::Time())); | 853 task_runner.get(), source_path, 0, base::Time())); |
844 | 854 |
845 scoped_ptr<FileStreamWriter> writer(FileStreamWriter::CreateForLocalFile( | 855 { |
846 task_runner.get(), dest_path, 0, FileStreamWriter::CREATE_NEW_FILE)); | 856 base::File file(dest_path, |
857 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | |
858 EXPECT_TRUE(file.created()); | |
859 } | |
860 scoped_ptr<FileStreamWriter> writer( | |
861 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); | |
847 | 862 |
848 std::vector<int64> progress; | 863 std::vector<int64> progress; |
849 CopyOrMoveOperationDelegate::StreamCopyHelper helper( | 864 CopyOrMoveOperationDelegate::StreamCopyHelper helper( |
850 reader.Pass(), writer.Pass(), | 865 reader.Pass(), writer.Pass(), |
851 storage::FlushPolicy::NO_FLUSH_ON_COMPLETION, | 866 storage::FlushPolicy::NO_FLUSH_ON_COMPLETION, |
852 10, // buffer size | 867 10, // buffer size |
853 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), | 868 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), |
854 base::TimeDelta()); // For testing, we need all the progress. | 869 base::TimeDelta()); // For testing, we need all the progress. |
855 | 870 |
856 // Call Cancel() later. | 871 // Call Cancel() later. |
857 base::MessageLoopProxy::current()->PostTask( | 872 base::MessageLoopProxy::current()->PostTask( |
858 FROM_HERE, | 873 FROM_HERE, |
859 base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel, | 874 base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel, |
860 base::Unretained(&helper))); | 875 base::Unretained(&helper))); |
861 | 876 |
862 base::File::Error error = base::File::FILE_ERROR_FAILED; | 877 base::File::Error error = base::File::FILE_ERROR_FAILED; |
863 base::RunLoop run_loop; | 878 base::RunLoop run_loop; |
864 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); | 879 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); |
865 run_loop.Run(); | 880 run_loop.Run(); |
866 | 881 |
867 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); | 882 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); |
868 } | 883 } |
869 | 884 |
870 } // namespace content | 885 } // namespace content |
OLD | NEW |