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

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

Issue 895933007: [Storage] Blob items are now shared between blobs. Ready for disk swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and added one more histogram Created 5 years, 10 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
« no previous file with comments | « storage/browser/blob/internal_blob_data.cc ('k') | storage/browser/blob/shareable_blob_data_item.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/shareable_blob_data_item.h
diff --git a/storage/browser/blob/shareable_blob_data_item.h b/storage/browser/blob/shareable_blob_data_item.h
new file mode 100644
index 0000000000000000000000000000000000000000..8df83895e40c1bc21def32c0d0dbd694682478d5
--- /dev/null
+++ b/storage/browser/blob/shareable_blob_data_item.h
@@ -0,0 +1,47 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_
+#define STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_
+
+#include "base/containers/hash_tables.h"
+#include "base/hash.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "storage/common/data_element.h"
+
+namespace storage {
+
+class BlobDataItem;
+
+// This class allows blob items to be shared between blobs, and is only used by
+// BlobStorageContext. This class contains both the blob data item and the uuids
+// of all the blobs using this item.
+// The data in this class (the item) is immutable, but the item itself can be
+// swapped out with an item with the same data but a different backing (think
+// RAM vs file backed).
+class ShareableBlobDataItem : public base::RefCounted<ShareableBlobDataItem> {
+ public:
+ ShareableBlobDataItem(const std::string& blob_uuid,
+ const scoped_refptr<BlobDataItem>& item);
+
+ const scoped_refptr<BlobDataItem>& item();
+
+ base::hash_set<std::string>& referencing_blobs() {
+ return referencing_blobs_;
+ }
+
+ private:
+ friend class base::RefCounted<ShareableBlobDataItem>;
+ ~ShareableBlobDataItem();
+
+ scoped_refptr<BlobDataItem> item_;
+
+ base::hash_set<std::string> referencing_blobs_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShareableBlobDataItem);
+};
+
+} // namespace storage
+#endif // STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_
« no previous file with comments | « storage/browser/blob/internal_blob_data.cc ('k') | storage/browser/blob/shareable_blob_data_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698