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

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: Use ScopedVector and stl_utils for BlobDataHandles. 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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
730 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); 730 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0,
731 true));
jsbell 2013/12/18 23:04:40 Ditto, etc.
ericu 2013/12/19 05:19:11 Done.
731 732
732 std::vector<int64> progress; 733 std::vector<int64> progress;
733 CopyOrMoveOperationDelegate::StreamCopyHelper helper( 734 CopyOrMoveOperationDelegate::StreamCopyHelper helper(
734 reader.Pass(), writer.Pass(), 735 reader.Pass(), writer.Pass(),
735 10, // buffer size 736 10, // buffer size
736 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), 737 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)),
737 base::TimeDelta()); // For testing, we need all the progress. 738 base::TimeDelta()); // For testing, we need all the progress.
738 739
739 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; 740 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
740 base::RunLoop run_loop; 741 base::RunLoop run_loop;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 ASSERT_TRUE(thread_stopper.is_valid()); 774 ASSERT_TRUE(thread_stopper.is_valid());
774 775
775 scoped_refptr<base::MessageLoopProxy> task_runner = 776 scoped_refptr<base::MessageLoopProxy> task_runner =
776 file_thread.message_loop_proxy(); 777 file_thread.message_loop_proxy();
777 778
778 scoped_ptr<webkit_blob::FileStreamReader> reader( 779 scoped_ptr<webkit_blob::FileStreamReader> reader(
779 webkit_blob::FileStreamReader::CreateForLocalFile( 780 webkit_blob::FileStreamReader::CreateForLocalFile(
780 task_runner.get(), source_path, 0, base::Time())); 781 task_runner.get(), source_path, 0, base::Time()));
781 782
782 scoped_ptr<FileStreamWriter> writer( 783 scoped_ptr<FileStreamWriter> writer(
783 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0)); 784 FileStreamWriter::CreateForLocalFile(task_runner.get(), dest_path, 0,
785 true));
784 786
785 std::vector<int64> progress; 787 std::vector<int64> progress;
786 CopyOrMoveOperationDelegate::StreamCopyHelper helper( 788 CopyOrMoveOperationDelegate::StreamCopyHelper helper(
787 reader.Pass(), writer.Pass(), 789 reader.Pass(), writer.Pass(),
788 10, // buffer size 790 10, // buffer size
789 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)), 791 base::Bind(&RecordFileProgressCallback, base::Unretained(&progress)),
790 base::TimeDelta()); // For testing, we need all the progress. 792 base::TimeDelta()); // For testing, we need all the progress.
791 793
792 // Call Cancel() later. 794 // Call Cancel() later.
793 base::MessageLoopProxy::current()->PostTask( 795 base::MessageLoopProxy::current()->PostTask(
794 FROM_HERE, 796 FROM_HERE,
795 base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel, 797 base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel,
796 base::Unretained(&helper))); 798 base::Unretained(&helper)));
797 799
798 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; 800 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
799 base::RunLoop run_loop; 801 base::RunLoop run_loop;
800 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); 802 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error));
801 run_loop.Run(); 803 run_loop.Run();
802 804
803 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, error); 805 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, error);
804 } 806 }
805 807
806 } // namespace fileapi 808 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698