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

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

Issue 2448353002: [BlobAsync] Moving async handling into BlobStorageContext & quota out. (Closed)
Patch Set: comments Created 4 years, 1 month 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 namespace {
11 11
12 uint64_t GetAndIncrementItemId() { 12 uint64_t GetAndIncrementItemId() {
13 static uint64_t sNextItemId = 0; 13 static uint64_t sNextItemId = 0;
14 return sNextItemId++; 14 return sNextItemId++;
15 } 15 }
16 16
17 } // namespace 17 } // namespace
18 18
19 ShareableBlobDataItem::ShareableBlobDataItem( 19 ShareableBlobDataItem::ShareableBlobDataItem(
20 const std::string& referencing_blob_uuid,
21 scoped_refptr<BlobDataItem> item, 20 scoped_refptr<BlobDataItem> item,
22 ShareableBlobDataItem::State state) 21 ShareableBlobDataItem::State state)
23 : item_id_(GetAndIncrementItemId()), state_(state), item_(std::move(item)) { 22 : item_id_(GetAndIncrementItemId()), state_(state), item_(std::move(item)) {
24 DCHECK_NE(item_->type(), DataElement::TYPE_BLOB); 23 DCHECK_NE(item_->type(), DataElement::TYPE_BLOB);
25 referencing_blobs_.insert(referencing_blob_uuid);
26 } 24 }
27 25
28 ShareableBlobDataItem::~ShareableBlobDataItem() { 26 ShareableBlobDataItem::~ShareableBlobDataItem() {
29 } 27 }
30 28
31 void ShareableBlobDataItem::set_item(scoped_refptr<BlobDataItem> item) { 29 void ShareableBlobDataItem::set_item(scoped_refptr<BlobDataItem> item) {
32 item_ = std::move(item); 30 item_ = std::move(item);
33 } 31 }
34 32
35 void PrintTo(const ShareableBlobDataItem& x, ::std::ostream* os) { 33 void PrintTo(const ShareableBlobDataItem& x, ::std::ostream* os) {
36 *os << "<ShareableBlobDataItem>{ item_id: " << x.item_id_ 34 *os << "<ShareableBlobDataItem>{ item_id: " << x.item_id_
37 << ", state: " << x.state_ << ", item: "; 35 << ", state: " << x.state_ << ", item: ";
38 PrintTo(*x.item_, os); 36 PrintTo(*x.item_, os);
39 *os << ", referencing_blobs: [";
40 for (const std::string& uuid : x.referencing_blobs()) {
41 *os << uuid << ", ";
42 }
43 *os << "]}"; 37 *os << "]}";
44 } 38 }
45 39
46 bool operator==(const ShareableBlobDataItem& a, 40 bool operator==(const ShareableBlobDataItem& a,
47 const ShareableBlobDataItem& b) { 41 const ShareableBlobDataItem& b) {
48 return a.item_id() == b.item_id() && *a.item() == *b.item() && 42 return a.item_id() == b.item_id() && *a.item() == *b.item();
49 a.referencing_blobs() == b.referencing_blobs();
50 } 43 }
51 44
52 bool operator!=(const ShareableBlobDataItem& a, 45 bool operator!=(const ShareableBlobDataItem& a,
53 const ShareableBlobDataItem& b) { 46 const ShareableBlobDataItem& b) {
54 return !(a == b); 47 return !(a == b);
55 } 48 }
56 49
57 } // namespace storage 50 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/blob/shareable_blob_data_item.h ('k') | storage/browser/blob/view_blob_internals_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698