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

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

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 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 #ifndef STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ 5 #ifndef STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_
6 #define STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ 6 #define STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/hash.h" 11 #include "base/hash.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "storage/common/data_element.h" 14 #include "storage/common/data_element.h"
15 15
16 namespace storage { 16 namespace storage {
17 class BlobDataItem; 17 class BlobDataItem;
18 class InternalBlobData; 18 class InternalBlobData;
19 19
20 // This class allows blob items to be shared between blobs, and is only used by 20 // This class allows blob items to be shared between blobs, and is only used by
21 // BlobStorageContext. This class contains both the blob data item and the uuids 21 // BlobStorageContext. This class contains both the blob data item and the uuids
22 // of all the blobs using this item. 22 // of all the blobs using this item.
23 // The data in this class (the item) is immutable, but the item itself can be 23 // The data in this class (the item) is immutable, but the item itself can be
24 // swapped out with an item with the same data but a different backing (think 24 // swapped out with an item with the same data but a different backing (think
25 // RAM vs file backed). 25 // RAM vs file backed).
26 class ShareableBlobDataItem : public base::RefCounted<ShareableBlobDataItem> { 26 class ShareableBlobDataItem
27 : public base::RefCountedThreadSafe<ShareableBlobDataItem> {
michaeln 2016/07/14 01:44:43 Why does this need to be a threadsafe refcount? If
dmurph 2016/07/15 20:18:15 We pass this to a file thread in the BlobMemoryCon
michaeln 2016/08/15 22:44:42 But if the Shareable item can be deref'd on the ba
27 public: 28 public:
28 ShareableBlobDataItem(const std::string& blob_uuid, 29 ShareableBlobDataItem(scoped_refptr<BlobDataItem> item);
29 const scoped_refptr<BlobDataItem>& item);
30 30
31 const scoped_refptr<BlobDataItem>& item(); 31 const scoped_refptr<BlobDataItem>& item();
32 32
33 // This is a unique auto-incrementing id assigned to this item on
34 // construction. It is used to keep track of this item in an LRU data
35 // structure for eviction to disk.
36 uint64_t item_id() const { return item_id_; }
37
33 base::hash_set<std::string>& referencing_blobs() { 38 base::hash_set<std::string>& referencing_blobs() {
34 return referencing_blobs_; 39 return referencing_blobs_;
35 } 40 }
36 41
37 private: 42 private:
38 friend class base::RefCounted<ShareableBlobDataItem>; 43 friend class base::RefCountedThreadSafe<ShareableBlobDataItem>;
39 friend class InternalBlobData; 44 friend class InternalBlobData;
45 friend class BlobMemoryController;
46 friend class BlobStorageContext;
40 ~ShareableBlobDataItem(); 47 ~ShareableBlobDataItem();
41 48
49 // This is a unique identifier for this ShareableBlobDataItem.
50 uint64_t item_id_;
42 scoped_refptr<BlobDataItem> item_; 51 scoped_refptr<BlobDataItem> item_;
43 52
44 base::hash_set<std::string> referencing_blobs_; 53 base::hash_set<std::string> referencing_blobs_;
45 54
46 DISALLOW_COPY_AND_ASSIGN(ShareableBlobDataItem); 55 DISALLOW_COPY_AND_ASSIGN(ShareableBlobDataItem);
47 }; 56 };
48 57
49 } // namespace storage 58 } // namespace storage
50 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ 59 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698