Chromium Code Reviews| 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 1953a1a6a2563ed3e3ed3467ea877a99185d05f8..66e76606a8873db1f3968c1a70568958a556ea23 100644 |
| --- a/storage/browser/blob/blob_data_item.h |
| +++ b/storage/browser/blob/blob_data_item.h |
| @@ -7,21 +7,40 @@ |
| #include "base/basictypes.h" |
| #include "base/memory/ref_counted.h" |
| -#include "storage/browser/blob/shareable_file_reference.h" |
| #include "storage/browser/storage_browser_export.h" |
| #include "storage/common/data_element.h" |
| +namespace disk_cache { |
| +class Entry; |
| +} |
| + |
| 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: |
| + // The DataHandle class is used to persist resources that are needed for |
| + // reading this BlobDataItem. This object will stay around while any reads are |
| + // pending. If all blobs with this item are deleted or the item is swapped for |
| + // a different backend version (mem-to-disk or the reverse), then the item |
| + // will be destructed after all pending reads are complete. |
| + class DataHandle : public base::RefCounted<DataHandle> { |
| + public: |
| + virtual disk_cache::Entry* disk_cache_entry() const; |
|
dmurph
2015/06/05 01:17:22
Sorry, why does this need to be here? To get the
gavinp
2015/06/05 15:10:34
BlobDataItem needs an implementation of disk_cache
|
| + |
| + protected: |
| + virtual ~DataHandle(); |
| + |
| + private: |
| + friend class base::RefCounted<DataHandle>; |
| + }; |
| + |
| DataElement::Type type() const { return item_->type(); } |
| const char* bytes() const { return item_->bytes(); } |
| const base::FilePath& path() const { return item_->path(); } |
| @@ -35,6 +54,11 @@ class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> { |
| const DataElement& data_element() const { return *item_; } |
| const DataElement* data_element_ptr() const { return item_.get(); } |
| + disk_cache::Entry* disk_cache_entry() const { |
| + return data_handle_ ? data_handle_->disk_cache_entry() : nullptr; |
| + } |
| + int disk_cache_stream_index() const { return disk_cache_stream_index_; } |
| + |
| private: |
| friend class BlobDataBuilder; |
| friend class BlobStorageContext; |
| @@ -42,16 +66,22 @@ class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> { |
| BlobDataItem(scoped_ptr<DataElement> item); |
| BlobDataItem(scoped_ptr<DataElement> item, |
| - scoped_refptr<ShareableFileReference> file_handle); |
| + const scoped_refptr<DataHandle>& data_handle); |
| + BlobDataItem(scoped_ptr<DataElement> item, |
| + const scoped_refptr<DataHandle>& data_handle, |
| + int disk_cache_stream_index_); |
| virtual ~BlobDataItem(); |
| scoped_ptr<DataElement> item_; |
| - scoped_refptr<ShareableFileReference> file_handle_; |
| + scoped_refptr<DataHandle> data_handle_; |
| + |
| + 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) { |