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

Unified Diff: storage/browser/blob/internal_blob_data.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back transport controller test, small cleanups Created 4 years, 6 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: storage/browser/blob/internal_blob_data.cc
diff --git a/storage/browser/blob/internal_blob_data.cc b/storage/browser/blob/internal_blob_data.cc
index 115c6a65e1f45265dff05d18054bf404455ecbfa..0668cfe1d4d60e828b62baaa0b60461583a69304 100644
--- a/storage/browser/blob/internal_blob_data.cc
+++ b/storage/browser/blob/internal_blob_data.cc
@@ -16,38 +16,19 @@
namespace storage {
-InternalBlobData::Builder::Builder() : data_(new InternalBlobData()) {
-}
-InternalBlobData::Builder::~Builder() {
-}
-
-void InternalBlobData::Builder::AppendSharedBlobItem(
- scoped_refptr<ShareableBlobDataItem> item) {
- DCHECK(item);
- DCHECK(data_);
- data_->items_.push_back(item);
-}
+InternalBlobData::InternalBlobData() {}
-void InternalBlobData::Builder::RemoveBlobFromShareableItems(
- const std::string& blob_uuid) {
- DCHECK(data_);
- data_->RemoveBlobFromShareableItems(blob_uuid);
-}
-
-size_t InternalBlobData::Builder::GetNonsharedMemoryUsage() const {
- DCHECK(data_);
- return data_->GetUnsharedMemoryUsage();
-}
-
-std::unique_ptr<InternalBlobData> InternalBlobData::Builder::Build() {
- DCHECK(data_);
- return std::move(data_);
-}
+InternalBlobData::~InternalBlobData() {}
-InternalBlobData::InternalBlobData() {
-}
-
-InternalBlobData::~InternalBlobData() {
+void InternalBlobData::AppendSharedBlobItem(
+ const std::string& my_uuid,
+ scoped_refptr<ShareableBlobDataItem> item) {
+ if (!items_.empty()) {
+ offsets_.push_back(size_);
+ }
+ size_ += item->item()->length();
+ item->referencing_blobs().insert(my_uuid);
+ items_.push_back(std::move(item));
}
const std::vector<scoped_refptr<ShareableBlobDataItem>>&
@@ -71,27 +52,11 @@ size_t InternalBlobData::GetUnsharedMemoryUsage() const {
seen_items.find(data_item.get()) != seen_items.end()) {
continue;
}
+ LOG(ERROR) << "no one else has item " << data_item->item_id();
memory += data_item->item()->length();
seen_items.insert(data_item.get());
}
return memory;
}
-void InternalBlobData::GetMemoryUsage(size_t* total_memory,
- size_t* unshared_memory) {
- *total_memory = 0;
- *unshared_memory = 0;
- base::hash_set<void*> seen_items;
- for (const auto& data_item : items_) {
- if (data_item->item()->type() == DataElement::TYPE_BYTES) {
- *total_memory += data_item->item()->length();
- if (data_item->referencing_blobs().size() == 1 &&
- seen_items.find(data_item.get()) == seen_items.end()) {
- *unshared_memory += data_item->item()->length();
- seen_items.insert(data_item.get());
- }
- }
- }
-}
-
} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698