diff options
author | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 16:58:06 +0000 |
---|---|---|
committer | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 16:58:06 +0000 |
commit | 2e4633c5b2a040357659646b951b632bff3055f5 (patch) | |
tree | f4a4ab7e636963a940118157cbec5dd4cc7b4ad4 /chrome/test | |
parent | dba526fa150d26deae1a10f54bc3b72ed36e5520 (diff) | |
download | chromium_src-2e4633c5b2a040357659646b951b632bff3055f5.zip chromium_src-2e4633c5b2a040357659646b951b632bff3055f5.tar.gz chromium_src-2e4633c5b2a040357659646b951b632bff3055f5.tar.bz2 |
A prototype of resource loading through automation
In a test scenario where we need to load resources over
automation, we intercept the URL reqeusts and serve
them using automation IPCs.
This resource loading can be enabled per tab created
by automation.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/145024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20267 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/automation/automation_messages.h | 72 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 29 |
2 files changed, 101 insertions, 0 deletions
diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index 6c198c9..f19a74f 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -223,6 +223,78 @@ struct ParamTraits<Reposition_Params> { }; #endif // defined(OS_WIN) +struct AutomationURLRequest { + std::string url; + std::string method; + std::string referrer; + std::string extra_request_headers; +}; + +// Traits for AutomationURLRequest structure to pack/unpack. +template <> +struct ParamTraits<AutomationURLRequest> { + typedef AutomationURLRequest param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.url); + WriteParam(m, p.method); + WriteParam(m, p.referrer); + WriteParam(m, p.extra_request_headers); + } + 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); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.url, l); + l->append(L", "); + LogParam(p.method, l); + l->append(L", "); + LogParam(p.referrer, l); + l->append(L", "); + LogParam(p.extra_request_headers, l); + l->append(L")"); + } +}; + +struct AutomationURLResponse { + std::string mime_type; + std::string headers; + int64 content_length; + base::Time last_modified; +}; + +// Traits for AutomationURLRequest structure to pack/unpack. +template <> +struct ParamTraits<AutomationURLResponse> { + typedef AutomationURLResponse param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.mime_type); + WriteParam(m, p.headers); + WriteParam(m, p.content_length); + WriteParam(m, p.last_modified); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->mime_type) && + ReadParam(m, iter, &p->headers) && + ReadParam(m, iter, &p->content_length) && + ReadParam(m, iter, &p->last_modified); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.mime_type, l); + l->append(L", "); + LogParam(p.headers, l); + l->append(L", "); + LogParam(p.content_length, l); + l->append(L", "); + LogParam(p.last_modified, l); + l->append(L")"); + } +}; + } // namespace IPC #define MESSAGES_INTERNAL_FILE \ diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 66b898e..1eac286 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -944,4 +944,33 @@ IPC_BEGIN_MESSAGES(Automation) int /* selected_command */) #endif // OS_WIN + // A URL request to be fetched via automation + IPC_MESSAGE_ROUTED3(AutomationMsg_RequestStart, + int /* tab_handle */, + int /* request_id */, + IPC::AutomationURLRequest /* request */) + + // Read data from a URL request to be fetched via automation + IPC_MESSAGE_ROUTED3(AutomationMsg_RequestRead, + int /* tab_handle */, + int /* request_id */, + int /* bytes_to_read */) + + // Response to a AutomationMsg_RequestStart message + IPC_MESSAGE_ROUTED3(AutomationMsg_RequestStarted, + int /* tab_handle */, + int /* request_id */, + IPC::AutomationURLResponse /* response */) + + // Data read via automation + IPC_MESSAGE_ROUTED3(AutomationMsg_RequestData, + int /* tab_handle */, + int /* request_id */, + std::string /* data */) + + IPC_MESSAGE_ROUTED3(AutomationMsg_RequestEnd, + int /* tab_handle */, + int /* request_id */, + URLRequestStatus /* status */) + IPC_END_MESSAGES(Automation) |