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

Unified Diff: webkit/blob/blob_data.h

Issue 7974011: Break large blobs into multiple ipcs during creation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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: webkit/blob/blob_data.h
===================================================================
--- webkit/blob/blob_data.h (revision 102191)
+++ webkit/blob/blob_data.h (working copy)
@@ -28,8 +28,7 @@
TYPE_BLOB
};
- class Item {
- public:
+ struct Item {
jianli 2011/09/23 23:00:42 Why do we need to change from class to struct?
michaeln 2011/09/24 01:15:24 To use the handy IPC_STRUCT macro stuff instead of
jianli 2011/09/27 01:12:18 Then we'd better remove the underscore suffix from
michaeln 2011/09/27 23:27:31 Done. This was a ripply change, had to update many
Item();
~Item();
@@ -55,6 +54,13 @@
length_ = length;
}
+ void SetToData(const char* data, uint64 length) {
jianli 2011/09/23 23:00:42 Does std::string data support 64-bit?
michaeln 2011/09/24 01:15:24 no, i'll change to uint32
+ 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() {
jianli 2011/09/23 23:00:42 Please add const modifier.
michaeln 2011/09/24 01:15:24 will do
+ int64 memory = 0;
+ for (std::vector<Item>::const_iterator iter = items_.begin();
+ iter != items_.end(); ++iter) {
+ if (iter->type() == TYPE_DATA)
jianli 2011/09/23 23:00:42 Do we also need to count the sub-blob?
michaeln 2011/09/24 01:15:24 No, they're 'canonicalized' into FILE or DATA item
+ memory += iter->data_.size();
+ }
+ return memory;
}
private:

Powered by Google App Engine
This is Rietveld 408576698