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

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

Issue 2339933004: [BlobStorage] BlobMemoryController & tests (Closed)
Patch Set: Comments, and made task base class for hopefully more simplicity Created 4 years, 3 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/shareable_blob_data_item.cc
diff --git a/storage/browser/blob/shareable_blob_data_item.cc b/storage/browser/blob/shareable_blob_data_item.cc
index 40aaf9c7e10d29d40acbc73798f67f6c16030b4d..4561503cb13437880ec87aad9b58f65def57f3bb 100644
--- a/storage/browser/blob/shareable_blob_data_item.cc
+++ b/storage/browser/blob/shareable_blob_data_item.cc
@@ -7,20 +7,46 @@
#include "storage/browser/blob/blob_data_item.h"
namespace storage {
+namespace {
-ShareableBlobDataItem::ShareableBlobDataItem(
- const std::string& blob_uuid,
- const scoped_refptr<BlobDataItem>& item)
- : item_(item) {
+uint64_t GetAndIncrementItemId() {
+ static uint64_t sNextItemId = 0;
+ return sNextItemId++;
+}
+
+} // namespace
+
+ShareableBlobDataItem::ShareableBlobDataItem(const std::string& target_uuid,
michaeln 2016/09/27 00:09:30 maybe name this "referencing_blob_uuid" for clarit
dmurph 2016/09/29 00:44:23 Done.
+ scoped_refptr<BlobDataItem> item,
+ ShareableBlobDataItem::State state)
+ : item_id_(GetAndIncrementItemId()), state_(state), item_(std::move(item)) {
DCHECK_NE(item_->type(), DataElement::TYPE_BLOB);
- referencing_blobs_.insert(blob_uuid);
+ referencing_blobs_.insert(target_uuid);
}
ShareableBlobDataItem::~ShareableBlobDataItem() {
}
-const scoped_refptr<BlobDataItem>& ShareableBlobDataItem::item() {
- return item_;
+void PrintTo(const ShareableBlobDataItem& x, ::std::ostream* os) {
+ *os << "<ShareableBlobDataItem>{ item_id: " << x.item_id_
+ << ", state: " << x.state_ << ", item: ";
+ PrintTo(*x.item_, os);
+ *os << ", referencing_blobs: [";
+ for (const std::string& uuid : x.referencing_blobs()) {
+ *os << uuid << ", ";
+ }
+ *os << "]}";
+}
+
+bool operator==(const ShareableBlobDataItem& a,
+ const ShareableBlobDataItem& b) {
+ return a.item_id() == b.item_id() && *a.item() == *b.item() &&
+ a.referencing_blobs() == b.referencing_blobs();
+}
+
+bool operator!=(const ShareableBlobDataItem& a,
+ const ShareableBlobDataItem& b) {
+ return !(a == b);
}
} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698