summaryrefslogtreecommitdiffstats
path: root/chrome/common/common_param_traits.h
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 00:22:37 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 00:22:37 +0000
commita9c7ecfca90bc3084af7a6741d57f95107e19826 (patch)
tree54e98fcf870078c6e8186081bb4faebaa693d283 /chrome/common/common_param_traits.h
parent803ef4ef5b14ff135b826425825291259f9ceeab (diff)
downloadchromium_src-a9c7ecfca90bc3084af7a6741d57f95107e19826.zip
chromium_src-a9c7ecfca90bc3084af7a6741d57f95107e19826.tar.gz
chromium_src-a9c7ecfca90bc3084af7a6741d57f95107e19826.tar.bz2
Cause POST data to be marhsaled across the automation interface when using AutomationMsg_RequestStart.
Review URL: http://codereview.chromium.org/159228 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/common_param_traits.h')
-rw-r--r--chrome/common/common_param_traits.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h
index c34d55f..3af3904 100644
--- a/chrome/common/common_param_traits.h
+++ b/chrome/common/common_param_traits.h
@@ -11,10 +11,13 @@
#ifndef CHROME_COMMON_COMMON_PARAM_TRAITS_H_
#define CHROME_COMMON_COMMON_PARAM_TRAITS_H_
+#include <vector>
+
#include "base/gfx/native_widget_types.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/transport_dib.h"
#include "ipc/ipc_message_utils.h"
+#include "net/base/upload_data.h"
#include "net/url_request/url_request_status.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/window_open_disposition.h"
@@ -215,6 +218,83 @@ struct ParamTraits<URLRequestStatus> {
}
};
+
+// Traits for net::UploadData::Element.
+template <>
+struct ParamTraits<net::UploadData::Element> {
+ typedef net::UploadData::Element param_type;
+ static void Write(Message* m, const param_type& p) {
+ 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 {
+ WriteParam(m, p.file_path());
+ WriteParam(m, p.file_range_offset());
+ WriteParam(m, p.file_range_length());
+ }
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ int type;
+ if (!ReadParam(m, iter, &type))
+ return false;
+ if (type == net::UploadData::TYPE_BYTES) {
+ const char* data;
+ int len;
+ if (!m->ReadData(iter, &data, &len))
+ return false;
+ r->SetToBytes(data, len);
+ } else {
+ DCHECK(type == net::UploadData::TYPE_FILE);
+ FilePath file_path;
+ uint64 offset, length;
+ if (!ReadParam(m, iter, &file_path))
+ return false;
+ if (!ReadParam(m, iter, &offset))
+ return false;
+ if (!ReadParam(m, iter, &length))
+ return false;
+ r->SetToFilePathRange(file_path, offset, length);
+ }
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<net::UploadData::Element>");
+ }
+};
+
+// Traits for net::UploadData.
+template <>
+struct ParamTraits<scoped_refptr<net::UploadData> > {
+ typedef scoped_refptr<net::UploadData> param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.get() != NULL);
+ if (p) {
+ WriteParam(m, p->elements());
+ WriteParam(m, p->identifier());
+ }
+ }
+ static bool 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<net::UploadData::Element> elements;
+ if (!ReadParam(m, iter, &elements))
+ return false;
+ int identifier;
+ if (!ReadParam(m, iter, &identifier))
+ return false;
+ *r = new net::UploadData;
+ (*r)->swap_elements(&elements);
+ (*r)->set_identifier(identifier);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<net::UploadData>");
+ }
+};
+
template<>
struct ParamTraits<ThumbnailScore> {
typedef ThumbnailScore param_type;