diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 00:22:37 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 00:22:37 +0000 |
commit | a9c7ecfca90bc3084af7a6741d57f95107e19826 (patch) | |
tree | 54e98fcf870078c6e8186081bb4faebaa693d283 /chrome | |
parent | 803ef4ef5b14ff135b826425825291259f9ceeab (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/browser/automation/url_request_automation_job.cc | 3 | ||||
-rw-r--r-- | chrome/common/common_param_traits.h | 80 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 74 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages.h | 10 |
4 files changed, 90 insertions, 77 deletions
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc index 6bd18a4..3bec65ae 100644 --- a/chrome/browser/automation/url_request_automation_job.cc +++ b/chrome/browser/automation/url_request_automation_job.cc @@ -300,7 +300,8 @@ void URLRequestAutomationJob::StartAsync() { request_->url().spec(), request_->method(), request_->referrer(), - request_->extra_request_headers() + request_->extra_request_headers(), + request_->get_upload() }; DCHECK(message_filter_); 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; diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index c6c457c..026ff36f 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -1153,81 +1153,7 @@ struct ParamTraits<ViewMsg_UploadFile_Params> { } }; -// 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>"); - } -}; // Traits for webkit_glue::PasswordFormDomManager::FillData. template <> diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index 7fa2aa7..f7f1762 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -13,7 +13,8 @@ #include "chrome/browser/tab_contents/security_style.h" #include "chrome/common/common_param_traits.h" #include "chrome/test/automation/automation_constants.h" -#include "ipc/ipc_message_utils.h" +#include "net/base/upload_data.h" + struct AutomationMsg_Find_Params { // Unused value, which exists only for backwards compat. @@ -230,6 +231,7 @@ struct AutomationURLRequest { std::string method; std::string referrer; std::string extra_request_headers; + scoped_refptr<net::UploadData> upload_data; }; // Traits for AutomationURLRequest structure to pack/unpack. @@ -241,12 +243,14 @@ struct ParamTraits<AutomationURLRequest> { WriteParam(m, p.method); WriteParam(m, p.referrer); WriteParam(m, p.extra_request_headers); + WriteParam(m, p.upload_data); } static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->method) && ReadParam(m, iter, &p->referrer) && - ReadParam(m, iter, &p->extra_request_headers); + ReadParam(m, iter, &p->extra_request_headers) && + ReadParam(m, iter, &p->upload_data); } static void Log(const param_type& p, std::wstring* l) { l->append(L"("); @@ -257,6 +261,8 @@ struct ParamTraits<AutomationURLRequest> { LogParam(p.referrer, l); l->append(L", "); LogParam(p.extra_request_headers, l); + l->append(L", "); + LogParam(p.upload_data, l); l->append(L")"); } }; |