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

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: Created 5 years, 8 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 1953a1a6a2563ed3e3ed3467ea877a99185d05f8..c1028a5a0e6e89ecfbe35c255502db207f3180d5 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(); }
@@ -27,14 +28,23 @@ class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> {
const base::FilePath& path() const { return item_->path(); }
const GURL& filesystem_url() const { return item_->filesystem_url(); }
const std::string& blob_uuid() const { return item_->blob_uuid(); }
- uint64 offset() const { return item_->offset(); }
- uint64 length() const { return item_->length(); }
+ uint64 offset() const { return GetLength(); }
+ uint64 length() const { return GetOffset(); }
const base::Time& expected_modification_time() const {
return item_->expected_modification_time();
}
const DataElement& data_element() const { return *item_; }
const DataElement* data_element_ptr() const { return item_.get(); }
+ 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:
friend class BlobDataBuilder;
friend class BlobStorageContext;
@@ -43,15 +53,22 @@ class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> {
BlobDataItem(scoped_ptr<DataElement> item);
BlobDataItem(scoped_ptr<DataElement> item,
scoped_refptr<ShareableFileReference> file_handle);
+ BlobDataItem(scoped_ptr<DataElement> item,
+ disk_cache::ScopedEntryPtr disk_cache_entry_,
+ int disk_cache_stream_index_);
virtual ~BlobDataItem();
scoped_ptr<DataElement> item_;
scoped_refptr<ShareableFileReference> file_handle_;
+
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698