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

Unified 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: Finished comments, added new pending enum state 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 side-by-side diff with in-line comments
Download patch
Index: storage/browser/blob/shareable_blob_data_item.h
diff --git a/storage/browser/blob/shareable_blob_data_item.h b/storage/browser/blob/shareable_blob_data_item.h
index 4c2f9c1833262d18dfa82b622abdfef8585b9541..9e50ed231e3d19351884a114c358c105a9d13f85 100644
--- a/storage/browser/blob/shareable_blob_data_item.h
+++ b/storage/browser/blob/shareable_blob_data_item.h
@@ -11,34 +11,48 @@
#include "base/hash.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "storage/browser/storage_browser_export.h"
#include "storage/common/data_element.h"
namespace storage {
class BlobDataItem;
class InternalBlobData;
-// This class allows blob items to be shared between blobs, and is only used by
-// BlobStorageContext. This class contains both the blob data item and the uuids
-// of all the blobs using this item.
+// This class allows blob items to be shared between blobs. This class contains
+// both the blob data item and the uuids of all the blobs using this item.
// The data in this class (the item) is immutable, but the item itself can be
// swapped out with an item with the same data but a different backing (think
// RAM vs file backed).
-class ShareableBlobDataItem : public base::RefCounted<ShareableBlobDataItem> {
+// We need to be RefCountedThreadSafe as references of this item is passed to a
+// file thread to save old memory items to disk.
+class STORAGE_EXPORT ShareableBlobDataItem
+ : public base::RefCountedThreadSafe<ShareableBlobDataItem> {
public:
- ShareableBlobDataItem(const std::string& blob_uuid,
- const scoped_refptr<BlobDataItem>& item);
+ ShareableBlobDataItem(scoped_refptr<BlobDataItem> item);
- const scoped_refptr<BlobDataItem>& item();
+ const scoped_refptr<BlobDataItem>& item() const;
- base::hash_set<std::string>& referencing_blobs() {
+ // This is a unique auto-incrementing id assigned to this item on
+ // construction. It is used to keep track of this item in an LRU data
+ // structure for eviction to disk.
+ uint64_t item_id() const { return item_id_; }
+
+ const base::hash_set<std::string>& referencing_blobs() const {
return referencing_blobs_;
}
private:
- friend class base::RefCounted<ShareableBlobDataItem>;
+ friend class base::RefCountedThreadSafe<ShareableBlobDataItem>;
friend class InternalBlobData;
+ friend class BlobMemoryController;
+ friend class BlobStorageContext;
+ friend STORAGE_EXPORT void PrintTo(const ShareableBlobDataItem& x,
+ ::std::ostream* os);
+
~ShareableBlobDataItem();
+ // This is a unique identifier for this ShareableBlobDataItem.
+ uint64_t item_id_;
kinuko 2016/07/17 16:15:47 const
dmurph 2016/07/19 02:26:28 Done.
scoped_refptr<BlobDataItem> item_;
base::hash_set<std::string> referencing_blobs_;
@@ -46,5 +60,10 @@ class ShareableBlobDataItem : public base::RefCounted<ShareableBlobDataItem> {
DISALLOW_COPY_AND_ASSIGN(ShareableBlobDataItem);
};
+STORAGE_EXPORT bool operator==(const ShareableBlobDataItem& a,
+ const ShareableBlobDataItem& b);
+STORAGE_EXPORT bool operator!=(const ShareableBlobDataItem& a,
+ const ShareableBlobDataItem& b);
+
} // namespace storage
#endif // STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_

Powered by Google App Engine
This is Rietveld 408576698