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

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
« no previous file with comments | « content/common/webkit_param_traits.cc ('k') | webkit/blob/blob_storage_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « content/common/webkit_param_traits.cc ('k') | webkit/blob/blob_storage_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698