diff options
author | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 20:02:05 +0000 |
---|---|---|
committer | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 20:02:05 +0000 |
commit | b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1 (patch) | |
tree | 8222cba1e35402823f1c1f2190052892cc7c1403 /webkit/blob/blob_url_request_job_unittest.cc | |
parent | 18016982fceb89f48ed18b72afbdb26521e47c23 (diff) | |
download | chromium_src-b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1.zip chromium_src-b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1.tar.gz chromium_src-b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1.tar.bz2 |
In BlobURLRequestJob, open files asynchronously to avoid blocking the IO thread
(and tripping thread restriction asserts).
The bug was found while trying to get FileWriter ui_tests to pass
(see http://codereview.chromium.org/6609040/).
This change also changes all callers to pass in a file_thread_proxy so
the class can assume it's there and pass it to FileUtilProxy.
Finally, it adds a BlobURLRequestJob test case that reads a file larger
than the buffer size, to better exercise the job's behavior when ReadRawData()
is called multiple times.
BUG=75548
TEST=test_shell_tests,ui_tests
Review URL: http://codereview.chromium.org/6612051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob/blob_url_request_job_unittest.cc')
-rw-r--r-- | webkit/blob/blob_url_request_job_unittest.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/webkit/blob/blob_url_request_job_unittest.cc b/webkit/blob/blob_url_request_job_unittest.cc index 1d7cd6c..5d318a3 100644 --- a/webkit/blob/blob_url_request_job_unittest.cc +++ b/webkit/blob/blob_url_request_job_unittest.cc @@ -7,6 +7,7 @@ #include "base/file_path.h" #include "base/file_util.h" +#include "base/message_loop_proxy.h" #include "base/scoped_temp_dir.h" #include "base/task.h" #include "base/threading/thread.h" @@ -249,8 +250,10 @@ class BlobURLRequestJobTest : public testing::Test { request_.reset(new net::URLRequest(GURL("blob:blah"), url_request_delegate_.get())); request_->set_method(method); - blob_url_request_job_ = new BlobURLRequestJob(request_.get(), - blob_data, NULL); + blob_url_request_job_ = new BlobURLRequestJob( + request_.get(), + blob_data, + base::MessageLoopProxy::CreateForCurrentThread()); // Start the request. if (!extra_headers.IsEmpty()) @@ -283,6 +286,20 @@ class BlobURLRequestJobTest : public testing::Test { TestSuccessRequest(blob_data, kTestFileData1); } + void TestGetLargeFileRequest() { + scoped_refptr<BlobData> blob_data(new BlobData()); + FilePath large_temp_file = temp_dir_.path().AppendASCII("LargeBlob.dat"); + std::string large_data; + large_data.reserve(kBufferSize * 5); + for (int i = 0; i < kBufferSize * 5; ++i) + large_data.append(1, static_cast<char>(i % 256)); + ASSERT_EQ(static_cast<int>(large_data.size()), + file_util::WriteFile(large_temp_file, large_data.data(), + large_data.size())); + blob_data->AppendFile(large_temp_file, 0, -1, base::Time()); + TestSuccessRequest(blob_data, large_data); + } + void TestGetNonExistentFileRequest() { FilePath non_existent_file = temp_file1_.InsertBeforeExtension(FILE_PATH_LITERAL("-na")); @@ -409,6 +426,10 @@ TEST_F(BlobURLRequestJobTest, TestGetSimpleFileRequest) { RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSimpleFileRequest); } +TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) { + RunTestOnIOThread(&BlobURLRequestJobTest::TestGetLargeFileRequest); +} + TEST_F(BlobURLRequestJobTest, TestGetSlicedDataRequest) { RunTestOnIOThread(&BlobURLRequestJobTest::TestGetSlicedDataRequest); } |