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

Unified Diff: content/browser/blob_storage/blob_reader_unittest.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
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..08c9d24cedbb9cf70e7b4934790112af29b94813 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, 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_.BreakAndFinishBlob(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, 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_.FinishedPopulatingBlob(kUuid);
base::RunLoop().RunUntilIdle();
CheckSizeCalculatedAsynchronously(kDataSize, size_result);
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kDataSize));

Powered by Google App Engine
This is Rietveld 408576698