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

Unified Diff: storage/browser/blob/internal_blob_data.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: 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/internal_blob_data.h
diff --git a/storage/browser/blob/internal_blob_data.h b/storage/browser/blob/internal_blob_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..0670831c0b847208d86a1c5caa6defde7bd33136
--- /dev/null
+++ b/storage/browser/blob/internal_blob_data.h
@@ -0,0 +1,76 @@
+// TODO: Insert description here. (generated by dmurph)
michaeln 2015/02/05 22:58:47 copyright headers please
dmurph 2015/02/06 01:32:30 Done.
+
+#ifndef STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_
+#define STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "storage/browser/blob/shareable_blob_data_item.h"
+
+namespace storage {
+
+// This class represents a blob in the BlobStorageContext. The
+// SharableBlobDataItem it contains must not have their refcounts modified
+// anywhere but through storage in this class, as the calls to
+// GetNonsharedMemoryUsage rely on the refcount number referring to the number
+// of blobs that have the given item.
+class InternalBlobData {
+ public:
+ class Builder {
michaeln 2015/02/05 22:58:47 It may be more clear to compose this differently?
dmurph 2015/02/06 01:32:30 Done, let me know what you think.
+ public:
+ Builder();
+ ~Builder();
+
+ void AppendSharedBlobItem(scoped_refptr<ShareableBlobDataItem> item);
+
+ size_t GetNonsharedMemoryUsage() const;
+
+ // Removes the given blob uuid from the internal ShareableBlobDataItems.
+ // This is called on destruction of the blob if we're still building it.
+ void RemoveBlobFromShareableItems(const std::string& blob_uuid);
+
+ void set_content_type(const std::string& content_type) {
+ content_type_ = content_type;
+ }
+
+ void set_content_disposition(const std::string& content_disposition) {
+ content_disposition_ = content_disposition;
+ }
+
+ private:
+ friend class InternalBlobData;
+
+ std::string content_type_;
+ std::string content_disposition_;
+ std::vector<scoped_refptr<ShareableBlobDataItem>> items_;
+ };
+
+ ~InternalBlobData();
+
+ // Removes the given blob uuid from the internal ShareableBlobDataItems.
+ // This is called when this blob is being destroyed.
+ void RemoveBlobFromShareableItems(const std::string& blob_uuid);
+
+ const std::vector<scoped_refptr<ShareableBlobDataItem>>& items() const;
+ const std::string& content_type() const;
+ const std::string& content_disposition() const;
+
+ size_t GetNonsharedMemoryUsage() const;
+
+ private:
+ friend class BlobStorageContext;
+ // Consumes the items in the builder, leaving it empty.
+ InternalBlobData(scoped_ptr<Builder> builder);
+
+ std::string content_type_;
+ std::string content_disposition_;
+ std::vector<scoped_refptr<ShareableBlobDataItem>> items_;
+
+ DISALLOW_COPY_AND_ASSIGN(InternalBlobData);
+};
+
+} // namespace storage
+#endif // STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_

Powered by Google App Engine
This is Rietveld 408576698