Skip to content

Commit

Permalink
[BlobStorage] BlobMemoryController & tests
Browse files Browse the repository at this point in the history
This is a split off of https://codereview.chromium.org/2055053003/.

This adds the BlobMemoryController & tests, as well as any other small
required changes. I avoided doing too much refactoring (like the move
to BlobStatus everywhere, and removing BlobStorageRegistry::Entry for
InternalBlobData) to just focus on the BlobMemoryController API.

BUG=375297
R=michaeln@chromium.org,kinuko@chromium.org,mek@chromium.org

Review-Url: https://chromiumcodereview.appspot.com/2339933004
Cr-Commit-Position: refs/heads/master@{#426901}
  • Loading branch information
dmurph authored and Commit bot committed Oct 21, 2016
1 parent 4feacb1 commit 0b0e36d
Show file tree
Hide file tree
Showing 19 changed files with 2,025 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ namespace storage {
namespace {

const char kNewUUID[] = "newUUID";
const base::FilePath kFuturePopulatingFilePath = base::FilePath::FromUTF8Unsafe(
std::string(BlobDataBuilder::kAppendFutureFileTemporaryFileName));
const char kFakeBlobUUID[] = "fakeBlob";

void AddMemoryItem(size_t length, std::vector<DataElement>* out) {
Expand Down Expand Up @@ -87,8 +85,7 @@ TEST(BlobAsyncTransportRequestBuilderTest, TestLargeBlockToFile) {
memory_item_request.message);

BlobDataBuilder expected_builder(kNewUUID);
expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 305,
base::Time::FromDoubleT(0));
expected_builder.AppendFutureFile(0, 305, 0);
EXPECT_EQ(expected_builder, builder);
}

Expand Down Expand Up @@ -131,12 +128,9 @@ TEST(BlobAsyncTransportRequestBuilderTest, TestLargeBlockToFiles) {
memory_item_request.message);

BlobDataBuilder expected_builder(kNewUUID);
expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 400,
base::Time::FromDoubleT(0));
expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 400,
base::Time::FromDoubleT(0));
expected_builder.AppendFile(kFuturePopulatingFilePath, 0, 200,
base::Time::FromDoubleT(0));
expected_builder.AppendFutureFile(0, 400, 0);
expected_builder.AppendFutureFile(0, 400, 1);
expected_builder.AppendFutureFile(0, 200, 2);
EXPECT_EQ(expected_builder, builder);
}

Expand Down
31 changes: 31 additions & 0 deletions content/browser/blob_storage/blob_data_builder_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "storage/browser/blob/blob_data_builder.h"

#include <string>

#include "base/logging.h"
#include "storage/common/data_element.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace storage {

TEST(BlobDataBuilderTest, TestFutureFiles) {
const std::string kId = "id";

DataElement element;
element.SetToFilePath(BlobDataBuilder::GetFutureFileItemPath(0));
EXPECT_TRUE(BlobDataBuilder::IsFutureFileItem(element));
EXPECT_EQ(0ull, BlobDataBuilder::GetFutureFileID(element));

BlobDataBuilder builder(kId);
builder.AppendFutureFile(0, 10, 0);
EXPECT_TRUE(
BlobDataBuilder::IsFutureFileItem(builder.items_[0]->data_element()));
EXPECT_EQ(0ull, BlobDataBuilder::GetFutureFileID(
builder.items_[0]->data_element()));
}

} // namespace storage
Loading

0 comments on commit 0b0e36d

Please sign in to comment.