Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 | |
| 3 #ifndef STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_ | |
| 4 #define STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_ | |
| 5 | |
| 6 #include <string> | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "storage/browser/blob/shareable_blob_data_item.h" | |
| 12 | |
| 13 namespace storage { | |
| 14 | |
| 15 // This class represents a blob in the BlobStorageContext. The | |
| 16 // SharableBlobDataItem it contains must not have their refcounts modified | |
| 17 // anywhere but through storage in this class, as the calls to | |
| 18 // GetNonsharedMemoryUsage rely on the refcount number referring to the number | |
| 19 // of blobs that have the given item. | |
| 20 class InternalBlobData { | |
| 21 public: | |
| 22 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.
| |
| 23 public: | |
| 24 Builder(); | |
| 25 ~Builder(); | |
| 26 | |
| 27 void AppendSharedBlobItem(scoped_refptr<ShareableBlobDataItem> item); | |
| 28 | |
| 29 size_t GetNonsharedMemoryUsage() const; | |
| 30 | |
| 31 // Removes the given blob uuid from the internal ShareableBlobDataItems. | |
| 32 // This is called on destruction of the blob if we're still building it. | |
| 33 void RemoveBlobFromShareableItems(const std::string& blob_uuid); | |
| 34 | |
| 35 void set_content_type(const std::string& content_type) { | |
| 36 content_type_ = content_type; | |
| 37 } | |
| 38 | |
| 39 void set_content_disposition(const std::string& content_disposition) { | |
| 40 content_disposition_ = content_disposition; | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 friend class InternalBlobData; | |
| 45 | |
| 46 std::string content_type_; | |
| 47 std::string content_disposition_; | |
| 48 std::vector<scoped_refptr<ShareableBlobDataItem>> items_; | |
| 49 }; | |
| 50 | |
| 51 ~InternalBlobData(); | |
| 52 | |
| 53 // Removes the given blob uuid from the internal ShareableBlobDataItems. | |
| 54 // This is called when this blob is being destroyed. | |
| 55 void RemoveBlobFromShareableItems(const std::string& blob_uuid); | |
| 56 | |
| 57 const std::vector<scoped_refptr<ShareableBlobDataItem>>& items() const; | |
| 58 const std::string& content_type() const; | |
| 59 const std::string& content_disposition() const; | |
| 60 | |
| 61 size_t GetNonsharedMemoryUsage() const; | |
| 62 | |
| 63 private: | |
| 64 friend class BlobStorageContext; | |
| 65 // Consumes the items in the builder, leaving it empty. | |
| 66 InternalBlobData(scoped_ptr<Builder> builder); | |
| 67 | |
| 68 std::string content_type_; | |
| 69 std::string content_disposition_; | |
| 70 std::vector<scoped_refptr<ShareableBlobDataItem>> items_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(InternalBlobData); | |
| 73 }; | |
| 74 | |
| 75 } // namespace storage | |
| 76 #endif // STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_ | |
| OLD | NEW |