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

Unified Diff: storage/browser/blob/blob_data_item.h

Issue 1108083002: Create blobs from Disk Cache entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased to upstream CL, review this upload Created 5 years, 7 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/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() {}
+ };
+
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_;
jkarlin 2015/05/29 14:59:41 file_handle_ should be converted to an ExtraData a
gavinp 2015/05/29 18:06:07 That's a good idea. dmurph, wdyt?
+ scoped_ptr<ExtraData> extra_data_;
+
+ disk_cache::ScopedEntryPtr disk_cache_entry_; // For TYPE_DISK_CACHE_ENTRY.
jkarlin 2015/05/29 14:59:41 Why store this here? Why not put it in a DataEleme
gavinp 2015/05/29 18:06:07 DataElement is a IPCable serializable entity; the
+ int disk_cache_stream_index_; // For TYPE_DISK_CACHE_ENTRY.
jkarlin 2015/05/29 14:59:41 ditto
};
#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) {

Powered by Google App Engine
This is Rietveld 408576698