| 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..399af8f4731de47bac1954b246d91678250d5e4d 100644
|
| --- a/content/browser/blob_storage/blob_reader_unittest.cc
|
| +++ b/content/browser/blob_storage/blob_reader_unittest.cc
|
| @@ -43,6 +43,7 @@ using base::FilePath;
|
| using content::AsyncFileTestHelper;
|
| using net::DrainableIOBuffer;
|
| using net::IOBuffer;
|
| +using FileCreationInfo = storage::BlobMemoryController::FileCreationInfo;
|
|
|
| namespace storage {
|
| namespace {
|
| @@ -50,6 +51,16 @@ namespace {
|
| const int kTestDiskCacheStreamIndex = 0;
|
| const int kTestDiskCacheSideStreamIndex = 1;
|
|
|
| +void SaveBlobStatusAndFiles(BlobStatus* status_ptr,
|
| + std::vector<FileCreationInfo>* files_ptr,
|
| + BlobStatus status,
|
| + std::vector<FileCreationInfo> files) {
|
| + *status_ptr = status;
|
| + for (FileCreationInfo& info : files) {
|
| + files_ptr->push_back(std::move(info));
|
| + }
|
| +}
|
| +
|
| // 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 +920,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 +1184,17 @@ TEST_F(BlobReaderTest, RangeError) {
|
|
|
| TEST_F(BlobReaderTest, HandleBeforeAsyncCancel) {
|
| const std::string kUuid("uuid1");
|
| + const std::string kData("Hello!!!");
|
| + const size_t kDataSize = 8ul;
|
| + std::vector<FileCreationInfo> files;
|
|
|
| - context_.CreatePendingBlob(kUuid, "", "");
|
| - blob_handle_ = context_.GetBlobDataFromUUID(kUuid);
|
| + BlobDataBuilder b(kUuid);
|
| + b.AppendFutureData(kDataSize);
|
| + BlobStatus can_populate_status =
|
| + BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS;
|
| + blob_handle_ = context_.BuildBlob(
|
| + b, base::Bind(&SaveBlobStatusAndFiles, &can_populate_status, &files));
|
| + EXPECT_EQ(BlobStatus::PENDING_TRANSPORT, can_populate_status);
|
| provider_ = new MockFileStreamReaderProvider();
|
| reader_.reset(new BlobReader(blob_handle_.get(), base::WrapUnique(provider_),
|
| message_loop_.task_runner().get()));
|
| @@ -1184,7 +1202,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_.CancelBuildingBlob(kUuid,
|
| + BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(net::ERR_FAILED, size_result);
|
| }
|
| @@ -1193,11 +1212,15 @@ TEST_F(BlobReaderTest, ReadFromIncompleteBlob) {
|
| const std::string kUuid("uuid1");
|
| const std::string kData("Hello!!!");
|
| const size_t kDataSize = 8ul;
|
| + std::vector<FileCreationInfo> files;
|
|
|
| BlobDataBuilder b(kUuid);
|
| - b.AppendData(kData);
|
| - context_.CreatePendingBlob(kUuid, "", "");
|
| - blob_handle_ = context_.GetBlobDataFromUUID(kUuid);
|
| + b.AppendFutureData(kDataSize);
|
| + BlobStatus can_populate_status =
|
| + BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS;
|
| + blob_handle_ = context_.BuildBlob(
|
| + b, base::Bind(&SaveBlobStatusAndFiles, &can_populate_status, &files));
|
| + EXPECT_EQ(BlobStatus::PENDING_TRANSPORT, can_populate_status);
|
| provider_ = new MockFileStreamReaderProvider();
|
| reader_.reset(new BlobReader(blob_handle_.get(), base::WrapUnique(provider_),
|
| message_loop_.task_runner().get()));
|
| @@ -1205,7 +1228,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_.NotifyTransportComplete(kUuid);
|
| base::RunLoop().RunUntilIdle();
|
| CheckSizeCalculatedAsynchronously(kDataSize, size_result);
|
| scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kDataSize));
|
|
|