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

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

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed copyright Created 5 years, 11 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_handle.h
diff --git a/storage/browser/blob/blob_data_handle.h b/storage/browser/blob/blob_data_handle.h
index 0b1d151c612e078ae6a91c3c052657a4f7d08e6a..30412415f76e68fb019f81a29b99743b51f8dd47 100644
--- a/storage/browser/blob/blob_data_handle.h
+++ b/storage/browser/blob/blob_data_handle.h
@@ -18,31 +18,44 @@ class SequencedTaskRunner;
namespace storage {
-class BlobData;
+class BlobDataSnapshot;
class BlobStorageContext;
-// A scoper object for use in chrome's main browser process, ensures
-// the underlying BlobData and its uuid remain in BlobStorageContext's
-// collection for the duration. This object has delete semantics and
-// maybe deleted on any thread.
+// BlobDataHandle ensures that the underlying blob (keyed by the uuid) remains
+// in the BlobStorageContext's collection while this object is alive. Anything
+// that needs to keep a blob alive needs to store this handle.
+// When the blob data itself is needed, clients must call the CreateSnapshot()
+// method on the IO thread to create a snapshot of the blob data. This snapshot
+// is not intended to be persisted, and serves to ensure that the backing
+// resources remain around for the duration of reading the blob. This snapshot
+// can be read on any thread, but it must be destructed on the IO thread.
+// This object has delete semantics and may be deleted on any thread.
class STORAGE_EXPORT BlobDataHandle
: public base::SupportsUserData::Data {
public:
BlobDataHandle(const BlobDataHandle& other); // May be copied on any thread.
- ~BlobDataHandle() override; // Maybe be deleted on any thread.
- BlobData* data() const; // May only be accessed on the IO thread.
+ ~BlobDataHandle() override; // May be deleted on any thread.
- std::string uuid() const; // May be accessed on any thread.
+ // A BlobDataSnapshot is used to read the data from the blob. This object is
+ // intended to be transient and should not be stored for any extended period
+ // of time.
+ // This call and the destruction of the returned snapshot must be called
+ // on the IO thread.
+ scoped_ptr<BlobDataSnapshot> CreateSnapshot() const;
+
+ const std::string& uuid() const; // May be accessed on any thread.
private:
+ // Internal class whose destructor is guarenteed to be called on the IO
+ // thread.
class BlobDataHandleShared
: public base::RefCountedThreadSafe<BlobDataHandleShared> {
public:
- BlobDataHandleShared(BlobData* blob_data,
+ BlobDataHandleShared(const std::string& uuid,
BlobStorageContext* context,
base::SequencedTaskRunner* task_runner);
- BlobData* data() const;
+ scoped_ptr<BlobDataSnapshot> CreateSnapshot() const;
const std::string& uuid() const;
private:
@@ -52,14 +65,15 @@ class STORAGE_EXPORT BlobDataHandle
virtual ~BlobDataHandleShared();
- scoped_refptr<BlobData> blob_data_;
+ const std::string uuid_;
base::WeakPtr<BlobStorageContext> context_;
DISALLOW_COPY_AND_ASSIGN(BlobDataHandleShared);
};
friend class BlobStorageContext;
- BlobDataHandle(BlobData* blob_data, BlobStorageContext* context,
+ BlobDataHandle(const std::string& uuid,
+ BlobStorageContext* context,
base::SequencedTaskRunner* task_runner);
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;

Powered by Google App Engine
This is Rietveld 408576698