Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle the rest of Josh's feedback. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 10 #include "base/file_util.h"
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 ScopedThreadStopper thread_stopper(&file_thread); 719 ScopedThreadStopper thread_stopper(&file_thread);
720 ASSERT_TRUE(thread_stopper.is_valid()); 720 ASSERT_TRUE(thread_stopper.is_valid());
721 721
722 scoped_refptr<base::MessageLoopProxy> task_runner = 722 scoped_refptr<base::MessageLoopProxy> task_runner =
723 file_thread.message_loop_proxy(); 723 file_thread.message_loop_proxy();
724 724
725 scoped_ptr<webkit_blob::FileStreamReader> reader( 725 scoped_ptr<webkit_blob::FileStreamReader> reader(
726 webkit_blob::FileStreamReader::CreateForLocalFile( 726 webkit_blob::FileStreamReader::CreateForLocalFile(
727 task_runner.get(), source_path, 0, base::Time())); 727 task_runner.get(), source_path, 0, base::Time()));
728 728
729 scoped_ptr<FileStreamWriter> writer( 729 scoped_ptr<FileStreamWriter> writer(FileStreamWriter::CreateForLocalFile(
730 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); 730 task_runner.get(), dest_path, 0, true));
731 731
732 std::vector<int64> progress; 732 std::vector<int64> progress;
733 CopyOrMoveOperationDelegate::StreamCopyHelper helper( 733 CopyOrMoveOperationDelegate::StreamCopyHelper helper(
734 reader.Pass(), writer.Pass(), 734 reader.Pass(), writer.Pass(),
735 10, // buffer size 735 10, // buffer size
736 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), 736 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)),
737 base::TimeDelta()); // For testing, we need all the progress. 737 base::TimeDelta()); // For testing, we need all the progress.
738 738
739 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; 739 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
740 base::RunLoop run_loop; 740 base::RunLoop run_loop;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 ScopedThreadStopper thread_stopper(&file_thread); 772 ScopedThreadStopper thread_stopper(&file_thread);
773 ASSERT_TRUE(thread_stopper.is_valid()); 773 ASSERT_TRUE(thread_stopper.is_valid());
774 774
775 scoped_refptr<base::MessageLoopProxy> task_runner = 775 scoped_refptr<base::MessageLoopProxy> task_runner =
776 file_thread.message_loop_proxy(); 776 file_thread.message_loop_proxy();
777 777
778 scoped_ptr<webkit_blob::FileStreamReader> reader( 778 scoped_ptr<webkit_blob::FileStreamReader> reader(
779 webkit_blob::FileStreamReader::CreateForLocalFile( 779 webkit_blob::FileStreamReader::CreateForLocalFile(
780 task_runner.get(), source_path, 0, base::Time())); 780 task_runner.get(), source_path, 0, base::Time()));
781 781
782 scoped_ptr<FileStreamWriter> writer( 782 scoped_ptr<FileStreamWriter> writer(FileStreamWriter::CreateForLocalFile(
783 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); 783 task_runner.get(), dest_path, 0, true));
784 784
785 std::vector<int64> progress; 785 std::vector<int64> progress;
786 CopyOrMoveOperationDelegate::StreamCopyHelper helper( 786 CopyOrMoveOperationDelegate::StreamCopyHelper helper(
787 reader.Pass(), writer.Pass(), 787 reader.Pass(), writer.Pass(),
788 10, // buffer size 788 10, // buffer size
789 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), 789 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)),
790 base::TimeDelta()); // For testing, we need all the progress. 790 base::TimeDelta()); // For testing, we need all the progress.
791 791
792 // Call Cancel() later. 792 // Call Cancel() later.
793 base::MessageLoopProxy::current()->PostTask( 793 base::MessageLoopProxy::current()->PostTask(
794 FROM_HERE, 794 FROM_HERE,
795 base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel, 795 base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel,
796 base::Unretained(&helper))); 796 base::Unretained(&helper)));
797 797
798 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; 798 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
799 base::RunLoop run_loop; 799 base::RunLoop run_loop;
800 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); 800 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error));
801 run_loop.Run(); 801 run_loop.Run();
802 802
803 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, error); 803 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, error);
804 } 804 }
805 805
806 } // namespace fileapi 806 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698