Index: storage/browser/blob/blob_data_item.h |
diff --git a/storage/browser/blob/blob_data_item.h b/storage/browser/blob/blob_data_item.h |
index 2b9d6e1bdcff37de3ef002b7c14cb8496348828d..29470d7283c4a84a4cc1e38161211645da11a742 100644 |
--- a/storage/browser/blob/blob_data_item.h |
+++ b/storage/browser/blob/blob_data_item.h |
@@ -7,6 +7,7 @@ |
#include "base/basictypes.h" |
#include "base/memory/ref_counted.h" |
+#include "net/disk_cache/disk_cache.h" |
#include "storage/browser/blob/shareable_file_reference.h" |
#include "storage/browser/storage_browser_export.h" |
#include "storage/common/data_element.h" |
@@ -15,11 +16,11 @@ namespace storage { |
class BlobDataBuilder; |
class BlobStorageContext; |
-// Ref counted blob item. This class owns the backing data of the blob item. |
-// The backing data is immutable, and cannot change after creation. |
-// The purpose of this class is to allow the resource to stick around in the |
-// snapshot even after the resource was swapped in the blob (either to disk or |
-// to memory) by the BlobStorageContext. |
+// Ref counted blob item. This class owns the backing data of the blob item. The |
+// backing data is immutable, and cannot change after creation. The purpose of |
+// this class is to allow the resource to stick around in the snapshot even |
+// after the resource was swapped in the blob (either to disk or to memory) by |
+// the BlobStorageContext. |
class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> { |
public: |
DataElement::Type type() const { return item_->type(); } |
@@ -33,26 +34,48 @@ class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> { |
const DataElement& data_element() const { return *item_; } |
const DataElement* data_element_ptr() const { return item_.get(); } |
- uint64 GetOffset() const { return item_->offset(); } |
- uint64 GetLength() const { return item_->length(); } |
+ const disk_cache::ScopedEntryPtr& disk_cache_entry() const { |
+ return disk_cache_entry_; |
+ } |
+ int disk_cache_stream_index() const { return disk_cache_stream_index_; } |
+ |
+ uint64 GetLength() const; |
+ uint64 GetOffset() const; |
private: |
+ // The ExtraData class owns data for the lifetime of this BlobDataItem. It is |
+ // used to ensure that required data for backing the blob has a lifetime of at |
+ // least the life of the blob. |
+ class ExtraData { |
+ public: |
+ virtual ~ExtraData() {} |
+ }; |
dmurph
2015/05/29 19:13:43
Hm, what about
// The DataHandle class is used to
gavinp
2015/06/04 18:40:00
Done. I avoided an extra layer of indirection in t
|
+ |
friend class BlobDataBuilder; |
friend class BlobStorageContext; |
friend class base::RefCounted<BlobDataItem>; |
BlobDataItem(scoped_ptr<DataElement> item); |
BlobDataItem(scoped_ptr<DataElement> item, |
- scoped_refptr<ShareableFileReference> file_handle); |
+ const scoped_refptr<ShareableFileReference>& file_handle); |
+ BlobDataItem(scoped_ptr<DataElement> item, |
+ scoped_ptr<ExtraData> extra_data, |
+ disk_cache::ScopedEntryPtr disk_cache_entry_, |
+ int disk_cache_stream_index_); |
virtual ~BlobDataItem(); |
scoped_ptr<DataElement> item_; |
scoped_refptr<ShareableFileReference> file_handle_; |
+ scoped_ptr<ExtraData> extra_data_; |
+ |
+ disk_cache::ScopedEntryPtr disk_cache_entry_; // For TYPE_DISK_CACHE_ENTRY. |
+ int disk_cache_stream_index_; // For TYPE_DISK_CACHE_ENTRY. |
}; |
#if defined(UNIT_TEST) |
inline bool operator==(const BlobDataItem& a, const BlobDataItem& b) { |
- return a.data_element() == b.data_element(); |
+ return a.disk_cache_entry() == b.disk_cache_entry() && |
+ a.data_element() == b.data_element(); |
} |
inline bool operator!=(const BlobDataItem& a, const BlobDataItem& b) { |