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

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: rebase Created 4 years, 2 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..84c1b4a3ba0b1f81c8851feb383e43fe365faece 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_.BreakAndFinishPendingBlob(
+ 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_.FinishedPopulatingPendingBlob(kUuid);
base::RunLoop().RunUntilIdle();
CheckSizeCalculatedAsynchronously(kDataSize, size_result);
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kDataSize));
« no previous file with comments | « content/browser/blob_storage/blob_memory_controller_unittest.cc ('k') | content/browser/blob_storage/blob_slice_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698