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

Side by Side Diff: storage/browser/blob/shareable_blob_data_item.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined BlobSlice & BlobFlattener files, more comments, a little cleanup. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "storage/browser/blob/shareable_blob_data_item.h" 5 #include "storage/browser/blob/shareable_blob_data_item.h"
6 6
7 #include "storage/browser/blob/blob_data_item.h" 7 #include "storage/browser/blob/blob_data_item.h"
8 8
9 namespace storage { 9 namespace storage {
10 namespace {
10 11
11 ShareableBlobDataItem::ShareableBlobDataItem( 12 uint64_t GetAndIncrementItemId() {
12 const std::string& blob_uuid, 13 static uint64_t sNextItemId = 0;
13 const scoped_refptr<BlobDataItem>& item) 14 return sNextItemId++;
14 : item_(item) { 15 }
16
17 } // namespace
18
19 ShareableBlobDataItem::ShareableBlobDataItem(scoped_refptr<BlobDataItem> item,
20 ShareableBlobDataItem::State state)
21 : item_id_(GetAndIncrementItemId()), state_(state), item_(std::move(item)) {
15 DCHECK_NE(item_->type(), DataElement::TYPE_BLOB); 22 DCHECK_NE(item_->type(), DataElement::TYPE_BLOB);
16 referencing_blobs_.insert(blob_uuid);
17 } 23 }
18 24
19 ShareableBlobDataItem::~ShareableBlobDataItem() { 25 ShareableBlobDataItem::~ShareableBlobDataItem() {
20 } 26 }
21 27
22 const scoped_refptr<BlobDataItem>& ShareableBlobDataItem::item() { 28 const scoped_refptr<BlobDataItem>& ShareableBlobDataItem::item() const {
23 return item_; 29 return item_;
24 } 30 }
25 31
32 void PrintTo(const ShareableBlobDataItem& x, ::std::ostream* os) {
33 *os << "<ShareableBlobDataItem>{ item_id: " << x.item_id_
34 << ", state: " << x.state_ << ", item: ";
35 PrintTo(*x.item_, os);
36 *os << ", referencing_blobs: [";
37 for (const std::string& uuid : x.referencing_blobs_) {
38 *os << uuid << ", ";
39 }
40 *os << "]}";
41 }
42
43 bool operator==(const ShareableBlobDataItem& a,
44 const ShareableBlobDataItem& b) {
45 return a.item_id() == b.item_id() && *a.item() == *b.item() &&
46 a.referencing_blobs() == b.referencing_blobs();
47 }
48
49 bool operator!=(const ShareableBlobDataItem& a,
50 const ShareableBlobDataItem& b) {
51 return !(a == b);
52 }
53
26 } // namespace storage 54 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698