Chromium Code Reviews| Index: webkit/blob/blob_data.h |
| =================================================================== |
| --- webkit/blob/blob_data.h (revision 102629) |
| +++ webkit/blob/blob_data.h (working copy) |
| @@ -28,8 +28,7 @@ |
| TYPE_BLOB |
| }; |
| - class Item { |
| - public: |
| + struct Item { |
| Item(); |
| ~Item(); |
| @@ -55,6 +54,13 @@ |
| length_ = length; |
| } |
| + void SetToData(const char* data, int length) { |
|
jianli
2011/09/27 01:12:18
Why not using uint32?
michaeln
2011/09/27 23:27:31
Done, switched to using size_t which is what std::
|
| + type_ = TYPE_DATA; |
| + data_.assign(data, length); |
| + offset_ = 0; |
| + length_ = length; |
| + } |
| + |
| void SetToFile(const FilePath& file_path, uint64 offset, uint64 length, |
| const base::Time& expected_modification_time) { |
| type_ = TYPE_FILE; |
| @@ -71,7 +77,6 @@ |
| length_ = length; |
| } |
| - private: |
| Type type_; |
| // For Data type. |
| @@ -91,6 +96,10 @@ |
| BlobData(); |
| explicit BlobData(const WebKit::WebBlobData& data); |
| + void AppendItem(const Item& item) { |
| + items_.push_back(item); |
| + } |
| + |
| void AppendData(const std::string& data) { |
| // TODO(jianli): Consider writing the big data to the disk. |
| AppendData(data, 0, static_cast<uint32>(data.size())); |
| @@ -133,9 +142,14 @@ |
| content_disposition_ = content_disposition; |
| } |
| - // Should only be called by the IPC ParamTraits for this class. |
| - void swap_items(std::vector<Item>* items) { |
| - items_.swap(*items); |
| + int64 GetMemoryUsage() const { |
| + int64 memory = 0; |
| + for (std::vector<Item>::const_iterator iter = items_.begin(); |
| + iter != items_.end(); ++iter) { |
| + if (iter->type() == TYPE_DATA) |
| + memory += iter->data_.size(); |
| + } |
| + return memory; |
| } |
| private: |