| Index: content/browser/blob_storage/blob_reader_unittest.cc
|
| diff --git a/content/browser/blob_storage/blob_reader_unittest.cc b/content/browser/blob_storage/blob_reader_unittest.cc
|
| index dd519a0946548c2582c569245de7dd040529764b..4fe177b97079dd7bff61a9bc1fd99fb35470c2e5 100644
|
| --- a/content/browser/blob_storage/blob_reader_unittest.cc
|
| +++ b/content/browser/blob_storage/blob_reader_unittest.cc
|
| @@ -50,6 +50,10 @@ namespace {
|
| const int kTestDiskCacheStreamIndex = 0;
|
| const int kTestDiskCacheSideStreamIndex = 1;
|
|
|
| +void CanPopulateDataCallback(BlobStatus* result_pointer, BlobStatus result) {
|
| + *result_pointer = result;
|
| +}
|
| +
|
| // Our disk cache tests don't need a real data handle since the tests themselves
|
| // scope the disk cache and entries.
|
| class EmptyDataHandle : public storage::BlobDataBuilder::DataHandle {
|
| @@ -909,8 +913,7 @@ TEST_F(BlobReaderTest, FileSomeAsyncSegmentedOffsetsUnknownSizes) {
|
| FilePath path = kPathBase.Append(
|
| FilePath::FromUTF8Unsafe(base::StringPrintf("%d", current_value)));
|
| uint64_t offset = i % 3 == 0 ? 1 : 0;
|
| - uint64_t size =
|
| - i % 2 == 0 ? kItemSize : std::numeric_limits<uint64_t>::max();
|
| + uint64_t size = kItemSize;
|
| b.AppendFile(path, offset, size, kTime);
|
| }
|
| this->InitializeReader(&b);
|
| @@ -1174,9 +1177,15 @@ TEST_F(BlobReaderTest, RangeError) {
|
|
|
| TEST_F(BlobReaderTest, HandleBeforeAsyncCancel) {
|
| const std::string kUuid("uuid1");
|
| + const std::string kData("Hello!!!");
|
| + const size_t kDataSize = 8ul;
|
|
|
| - context_.CreatePendingBlob(kUuid, "", "");
|
| - blob_handle_ = context_.GetBlobDataFromUUID(kUuid);
|
| + BlobDataBuilder b(kUuid);
|
| + b.AppendFutureData(kDataSize);
|
| + BlobStatus can_populate_status = BlobStatus::INVALID_CONSTRUCTION_ARGUMENTS;
|
| + blob_handle_ = context_.BuildBlob(
|
| + b, base::Bind(&CanPopulateDataCallback, &can_populate_status));
|
| + EXPECT_EQ(BlobStatus::PENDING_DATA_POPULATION, can_populate_status);
|
| provider_ = new MockFileStreamReaderProvider();
|
| reader_.reset(new BlobReader(blob_handle_.get(), base::WrapUnique(provider_),
|
| message_loop_.task_runner().get()));
|
| @@ -1184,7 +1193,8 @@ TEST_F(BlobReaderTest, HandleBeforeAsyncCancel) {
|
| EXPECT_EQ(BlobReader::Status::IO_PENDING,
|
| reader_->CalculateSize(base::Bind(&SetValue<int>, &size_result)));
|
| EXPECT_FALSE(reader_->IsInMemory());
|
| - context_.CancelPendingBlob(kUuid, IPCBlobCreationCancelCode::UNKNOWN);
|
| + context_.BreakAndFinishPendingBlob(
|
| + kUuid, BlobStatus::INVALID_CONSTRUCTION_ARGUMENTS);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(net::ERR_FAILED, size_result);
|
| }
|
| @@ -1195,9 +1205,11 @@ TEST_F(BlobReaderTest, ReadFromIncompleteBlob) {
|
| const size_t kDataSize = 8ul;
|
|
|
| BlobDataBuilder b(kUuid);
|
| - b.AppendData(kData);
|
| - context_.CreatePendingBlob(kUuid, "", "");
|
| - blob_handle_ = context_.GetBlobDataFromUUID(kUuid);
|
| + b.AppendFutureData(kDataSize);
|
| + BlobStatus can_populate_status = BlobStatus::INVALID_CONSTRUCTION_ARGUMENTS;
|
| + blob_handle_ = context_.BuildBlob(
|
| + b, base::Bind(&CanPopulateDataCallback, &can_populate_status));
|
| + EXPECT_EQ(BlobStatus::PENDING_DATA_POPULATION, can_populate_status);
|
| provider_ = new MockFileStreamReaderProvider();
|
| reader_.reset(new BlobReader(blob_handle_.get(), base::WrapUnique(provider_),
|
| message_loop_.task_runner().get()));
|
| @@ -1205,7 +1217,8 @@ TEST_F(BlobReaderTest, ReadFromIncompleteBlob) {
|
| EXPECT_EQ(BlobReader::Status::IO_PENDING,
|
| reader_->CalculateSize(base::Bind(&SetValue<int>, &size_result)));
|
| EXPECT_FALSE(reader_->IsInMemory());
|
| - context_.CompletePendingBlob(b);
|
| + b.PopulateFutureData(0, kData.data(), 0, kDataSize);
|
| + context_.FinishedPopulatingPendingBlob(kUuid);
|
| base::RunLoop().RunUntilIdle();
|
| CheckSizeCalculatedAsynchronously(kDataSize, size_result);
|
| scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kDataSize));
|
|
|