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

Unified Diff: chrome/common/common_param_traits.cc

Issue 3108042: Support sending BlobData to browser process. Also support sending UploadData... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | « chrome/common/common_param_traits.h ('k') | chrome/common/render_messages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/common_param_traits.cc
===================================================================
--- chrome/common/common_param_traits.cc (revision 57697)
+++ chrome/common/common_param_traits.cc (working copy)
@@ -17,6 +17,7 @@
#ifndef EXCLUDE_SKIA_DEPENDENCIES
#include "third_party/skia/include/core/SkBitmap.h"
#endif
+#include "webkit/blob/blob_data.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/password_form.h"
@@ -327,11 +328,13 @@
WriteParam(m, static_cast<int>(p.type()));
if (p.type() == net::UploadData::TYPE_BYTES) {
m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size()));
- } else {
+ } else if (p.type() == net::UploadData::TYPE_FILE) {
WriteParam(m, p.file_path());
WriteParam(m, p.file_range_offset());
WriteParam(m, p.file_range_length());
WriteParam(m, p.expected_file_modification_time());
+ } else {
+ WriteParam(m, p.blob_url());
}
}
static bool Read(const Message* m, void** iter, param_type* r) {
@@ -344,8 +347,7 @@
if (!m->ReadData(iter, &data, &len))
return false;
r->SetToBytes(data, len);
- } else {
- DCHECK(type == net::UploadData::TYPE_FILE);
+ } else if (type == net::UploadData::TYPE_FILE) {
FilePath file_path;
uint64 offset, length;
base::Time expected_modification_time;
@@ -359,6 +361,12 @@
return false;
r->SetToFilePathRange(file_path, offset, length,
expected_modification_time);
+ } else {
+ DCHECK(type == net::UploadData::TYPE_BLOB);
+ GURL blob_url;
+ if (!ReadParam(m, iter, &blob_url))
+ return false;
+ r->SetToBlobUrl(blob_url);
}
return true;
}
@@ -401,6 +409,106 @@
l->append("<net::UploadData>");
}
+// Only the webkit_blob::BlobData ParamTraits<> definition needs this
+// definition, so keep this in the implementation file so we can forward declare
+// BlobData in the header.
+template <>
+struct ParamTraits<webkit_blob::BlobData::Item> {
+ typedef webkit_blob::BlobData::Item param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p.type()));
+ if (p.type() == webkit_blob::BlobData::TYPE_DATA) {
+ WriteParam(m, p.data());
+ } else if (p.type() == webkit_blob::BlobData::TYPE_FILE) {
+ WriteParam(m, p.file_path());
+ WriteParam(m, p.offset());
+ WriteParam(m, p.length());
+ WriteParam(m, p.expected_modification_time());
+ } else {
+ WriteParam(m, p.blob_url());
+ WriteParam(m, p.offset());
+ WriteParam(m, p.length());
+ }
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ int type;
+ if (!ReadParam(m, iter, &type))
+ return false;
+ if (type == webkit_blob::BlobData::TYPE_DATA) {
+ std::string data;
+ if (!ReadParam(m, iter, &data))
+ return false;
+ r->SetToData(data);
+ } else if (type == webkit_blob::BlobData::TYPE_FILE) {
+ FilePath file_path;
+ uint64 offset, length;
+ base::Time expected_modification_time;
+ if (!ReadParam(m, iter, &file_path))
+ return false;
+ if (!ReadParam(m, iter, &offset))
+ return false;
+ if (!ReadParam(m, iter, &length))
+ return false;
+ if (!ReadParam(m, iter, &expected_modification_time))
+ return false;
+ r->SetToFile(file_path, offset, length, expected_modification_time);
+ } else {
+ DCHECK(type == webkit_blob::BlobData::TYPE_BLOB);
+ GURL blob_url;
+ uint64 offset, length;
+ if (!ReadParam(m, iter, &blob_url))
+ return false;
+ if (!ReadParam(m, iter, &offset))
+ return false;
+ if (!ReadParam(m, iter, &length))
+ return false;
+ r->SetToBlob(blob_url, offset, length);
+ }
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ l->append("<BlobData::Item>");
+ }
+};
+
+void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Write(
+ Message* m, const param_type& p) {
+ WriteParam(m, p.get() != NULL);
+ if (p) {
+ WriteParam(m, p->items());
+ WriteParam(m, p->content_type());
+ WriteParam(m, p->content_disposition());
+ }
+}
+
+bool ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Read(
+ const Message* m, void** iter, param_type* r) {
+ bool has_object;
+ if (!ReadParam(m, iter, &has_object))
+ return false;
+ if (!has_object)
+ return true;
+ std::vector<webkit_blob::BlobData::Item> items;
+ if (!ReadParam(m, iter, &items))
+ return false;
+ std::string content_type;
+ if (!ReadParam(m, iter, &content_type))
+ return false;
+ std::string content_disposition;
+ if (!ReadParam(m, iter, &content_disposition))
+ return false;
+ *r = new webkit_blob::BlobData;
+ (*r)->swap_items(&items);
+ (*r)->set_content_type(content_type);
+ (*r)->set_content_disposition(content_disposition);
+ return true;
+}
+
+void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log(
+ const param_type& p, std::string* l) {
+ l->append("<webkit_blob::BlobData>");
+}
+
void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) {
IPC::ParamTraits<double>::Write(m, p.boring_score);
IPC::ParamTraits<bool>::Write(m, p.good_clipping);
« no previous file with comments | « chrome/common/common_param_traits.h ('k') | chrome/common/render_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698