Chromium Code Reviews| 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 |
| index 65db2f3cdc322fe85a8c01e275d2c988601b95e9..6680fb07fc6866aa9796137164d7f8b5b35e0825 100644 |
| --- a/storage/browser/blob/internal_blob_data.h |
| +++ b/storage/browser/blob/internal_blob_data.h |
| @@ -18,8 +18,7 @@ |
| namespace storage { |
| class ViewBlobInternalsJob; |
| -// This class represents a blob in the BlobStorageContext. It is constructed |
| -// using the internal Builder class. |
| +// This class represents a blob in the BlobStorageContext. |
| class InternalBlobData { |
| public: |
| ~InternalBlobData(); |
| @@ -28,53 +27,46 @@ class InternalBlobData { |
| friend class BlobStorageContext; |
| friend class BlobStorageRegistry; |
| friend class ViewBlobInternalsJob; |
| + friend class BlobFlattener; |
| + friend class BlobSlice; |
| + |
| + InternalBlobData(); |
| + |
| + // Appends |
|
michaeln
2016/07/07 20:05:22
nit: comment isn't useful
|
| + void AppendSharedBlobItem(const std::string& my_uuid, |
| + scoped_refptr<ShareableBlobDataItem> item); |
| // 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::vector<size_t>& offsets() const { return offsets_; } |
| // Gets the memory used by this blob that is not shared by other blobs. This |
| // also doesn't count duplicate items. |
| size_t GetUnsharedMemoryUsage() const; |
| - // Gets the memory used by this blob. Total memory includes memory of items |
| - // possibly shared with other blobs, or items that appear multiple times in |
| - // this blob. Unshared memory is memory used by this blob that is not shared |
| - // by other blobs. |
| - void GetMemoryUsage(size_t* total_memory, size_t* unshared_memory); |
| + // Total size of this blob in bytes. |
| + uint64_t total_size() { return size_; }; |
| + |
| + // Size of this blob that isn't shared from another blob. |
| + uint64_t unique_size() { return size_; }; |
|
michaeln
2016/07/07 20:05:22
we should probably merge these two getters into on
|
| private: |
| friend class Builder; |
|
michaeln
2016/07/07 20:05:22
Builder is no longer used defined?
|
| - InternalBlobData(); |
| + friend class BlobStorageContext; |
| - std::string content_type_; |
| - std::string content_disposition_; |
| std::vector<scoped_refptr<ShareableBlobDataItem>> items_; |
| - class Builder { |
| - public: |
| - Builder(); |
| - ~Builder(); |
| - |
| - void AppendSharedBlobItem(scoped_refptr<ShareableBlobDataItem> item); |
| - |
| - // Gets the memory used by this builder that is not shared with other blobs. |
| - 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); |
| - |
| - // The builder is invalid after calling this method. |
| - std::unique_ptr<::storage::InternalBlobData> Build(); |
| - |
| - private: |
| - std::unique_ptr<::storage::InternalBlobData> data_; |
| + // Size in bytes. If we're a single file then this can be uint64_max. |
| + uint64_t size_ = 0; |
| + // Size of the data copying from other blobs. |
| + uint64_t copying_size_ = 0; |
| - DISALLOW_COPY_AND_ASSIGN(Builder); |
| - }; |
| + // Only populated if len(items_) > 1. Used for binary search. |
| + // Since the offset of the first item is always 0, we exclude this. |
| + std::vector<uint64_t> offsets_; |
| DISALLOW_COPY_AND_ASSIGN(InternalBlobData); |
| }; |