diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-05 19:08:32 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-05 19:08:32 +0000 |
commit | 94dc971dc40c6cfea33abd234e744ac314d0bc2a (patch) | |
tree | 0f2f3f0b57dfdb01c65afc6833e7ad622eb85697 /content | |
parent | a14ea34921d1347ceca1c8ddaa6dc1cf6efb1ddb (diff) | |
download | chromium_src-94dc971dc40c6cfea33abd234e744ac314d0bc2a.zip chromium_src-94dc971dc40c6cfea33abd234e744ac314d0bc2a.tar.gz chromium_src-94dc971dc40c6cfea33abd234e744ac314d0bc2a.tar.bz2 |
Move resource related IPCs to their own file in content. I added a IPC_STRUCT_TRAITS_PARENT macro to allow the automatic serializing macros to add a parent struct.
TBR=tsepez
Review URL: http://codereview.chromium.org/6628035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
20 files changed, 782 insertions, 64 deletions
diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index 4d1301a..355ce0e 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -38,6 +38,7 @@ #include "content/browser/plugin_service.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_message_filter.h" +#include "content/common/resource_messages.h" #include "ipc/ipc_switches.h" #include "net/base/cookie_store.h" #include "net/base/io_buffer.h" @@ -70,7 +71,7 @@ class PluginURLRequestContextOverride } virtual net::URLRequestContext* GetRequestContext( - const ViewHostMsg_Resource_Request& resource_request) { + const ResourceHostMsg_Request& resource_request) { return CPBrowsingContextManager::GetInstance()->ToURLRequestContext( resource_request.request_context); } diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc index 937f120..fb7b8d9 100644 --- a/content/browser/renderer_host/async_resource_handler.cc +++ b/content/browser/renderer_host/async_resource_handler.cc @@ -14,11 +14,12 @@ #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/load_timing_observer.h" #include "chrome/common/render_messages.h" -#include "chrome/common/resource_response.h" #include "content/browser/renderer_host/global_request_id.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/renderer_host/resource_message_filter.h" +#include "content/common/resource_response.h" +#include "content/common/resource_messages.h" #include "net/base/io_buffer.h" #include "net/base/load_flags.h" #include "net/base/net_log.h" @@ -91,9 +92,8 @@ AsyncResourceHandler::~AsyncResourceHandler() { bool AsyncResourceHandler::OnUploadProgress(int request_id, uint64 position, uint64 size) { - return filter_->Send(new ViewMsg_Resource_UploadProgress(routing_id_, - request_id, - position, size)); + return filter_->Send(new ResourceMsg_UploadProgress(routing_id_, request_id, + position, size)); } bool AsyncResourceHandler::OnRequestRedirected(int request_id, @@ -105,7 +105,7 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id, GlobalRequestID(filter_->child_id(), request_id)); LoadTimingObserver::PopulateTimingInfo(request, response); DevToolsNetLogObserver::PopulateResponseInfo(request, response); - return filter_->Send(new ViewMsg_Resource_ReceivedRedirect( + return filter_->Send(new ResourceMsg_ReceivedRedirect( routing_id_, request_id, new_url, response->response_head)); } @@ -137,14 +137,14 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, } } - filter_->Send(new ViewMsg_Resource_ReceivedResponse( + filter_->Send(new ResourceMsg_ReceivedResponse( routing_id_, request_id, response->response_head)); if (request->response_info().metadata) { std::vector<char> copy(request->response_info().metadata->data(), request->response_info().metadata->data() + request->response_info().metadata->size()); - filter_->Send(new ViewMsg_Resource_ReceivedCachedMetadata( + filter_->Send(new ResourceMsg_ReceivedCachedMetadata( routing_id_, request_id, copy)); } @@ -215,7 +215,7 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { // We just unmapped the memory. read_buffer_ = NULL; - filter_->Send(new ViewMsg_Resource_DataReceived( + filter_->Send(new ResourceMsg_DataReceived( routing_id_, request_id, handle, *bytes_read)); return true; @@ -223,7 +223,7 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { void AsyncResourceHandler::OnDataDownloaded( int request_id, int bytes_downloaded) { - filter_->Send(new ViewMsg_Resource_DataDownloaded( + filter_->Send(new ResourceMsg_DataDownloaded( routing_id_, request_id, bytes_downloaded)); } @@ -232,11 +232,11 @@ bool AsyncResourceHandler::OnResponseCompleted( const net::URLRequestStatus& status, const std::string& security_info) { Time completion_time = Time::Now(); - filter_->Send(new ViewMsg_Resource_RequestComplete(routing_id_, - request_id, - status, - security_info, - completion_time)); + filter_->Send(new ResourceMsg_RequestComplete(routing_id_, + request_id, + status, + security_info, + completion_time)); // If we still have a read buffer, then see about caching it for later... // Note that we have to make sure the buffer is not still being used, so we diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index 4923ca7..570d933 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -11,12 +11,12 @@ #include "base/string_util.h" #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" #include "chrome/common/extensions/user_script.h" -#include "chrome/common/resource_response.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" +#include "content/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" #include "net/base/mime_util.h" diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.cc b/content/browser/renderer_host/redirect_to_file_resource_handler.cc index bb18a4a..952a896 100644 --- a/content/browser/renderer_host/redirect_to_file_resource_handler.cc +++ b/content/browser/renderer_host/redirect_to_file_resource_handler.cc @@ -9,8 +9,8 @@ #include "base/logging.h" #include "base/platform_file.h" #include "base/task.h" -#include "chrome/common/resource_response.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" +#include "content/common/resource_response.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index 869c92d..6ed17f1 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -61,6 +61,7 @@ #include "content/browser/renderer_host/resource_request_details.h" #include "content/browser/renderer_host/sync_resource_handler.h" #include "content/browser/worker_host/worker_service.h" +#include "content/common/resource_messages.h" #include "net/base/auth.h" #include "net/base/cert_status_flags.h" #include "net/base/cookie_monster.h" @@ -126,7 +127,7 @@ const int kMaxOutstandingRequestsCostPerProcess = 26214400; // if the renderer is attempting to upload an unauthorized file. bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, int child_id, - const ViewHostMsg_Resource_Request& request_data) { + const ResourceHostMsg_Request& request_data) { if (process_type == ChildProcessInfo::PLUGIN_PROCESS) return true; @@ -312,15 +313,15 @@ bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, filter_ = filter; bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) - IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) - IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) - IPC_MESSAGE_HANDLER(ViewHostMsg_ReleaseDownloadedFile, + IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) + IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, OnReleaseDownloadedFile) - IPC_MESSAGE_HANDLER(ViewHostMsg_DataReceived_ACK, OnDataReceivedACK) - IPC_MESSAGE_HANDLER(ViewHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) - IPC_MESSAGE_HANDLER(ViewHostMsg_UploadProgress_ACK, OnUploadProgressACK) - IPC_MESSAGE_HANDLER(ViewHostMsg_CancelRequest, OnCancelRequest) - IPC_MESSAGE_HANDLER(ViewHostMsg_FollowRedirect, OnFollowRedirect) + IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) + IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) + IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) + IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) + IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -332,7 +333,7 @@ bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, void ResourceDispatcherHost::OnRequestResource( const IPC::Message& message, int request_id, - const ViewHostMsg_Resource_Request& request_data) { + const ResourceHostMsg_Request& request_data) { BeginRequest(request_id, request_data, NULL, message.routing_id()); } @@ -346,7 +347,7 @@ void ResourceDispatcherHost::OnRequestResource( // a normal asynchronous set of response messages will be generated. void ResourceDispatcherHost::OnSyncLoad( int request_id, - const ViewHostMsg_Resource_Request& request_data, + const ResourceHostMsg_Request& request_data, IPC::Message* sync_result) { BeginRequest(request_id, request_data, sync_result, sync_result->routing_id()); @@ -354,7 +355,7 @@ void ResourceDispatcherHost::OnSyncLoad( void ResourceDispatcherHost::BeginRequest( int request_id, - const ViewHostMsg_Resource_Request& request_data, + const ResourceHostMsg_Request& request_data, IPC::Message* sync_result, // only valid for sync int route_id) { ChildProcessInfo::ProcessType process_type = filter_->process_type(); @@ -376,11 +377,11 @@ void ResourceDispatcherHost::BeginRequest( if (sync_result) { SyncLoadResult result; result.status = status; - ViewHostMsg_SyncLoad::WriteReplyParams(sync_result, result); + ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); filter_->Send(sync_result); } else { // Tell the renderer that this request was disallowed. - filter_->Send(new ViewMsg_Resource_RequestComplete( + filter_->Send(new ResourceMsg_RequestComplete( route_id, request_id, status, diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h index 47dcb22..0dbe8712 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.h +++ b/content/browser/renderer_host/resource_dispatcher_host.h @@ -45,7 +45,7 @@ class UserScriptListener; class WebKitThread; struct DownloadSaveInfo; struct GlobalRequestID; -struct ViewHostMsg_Resource_Request; +struct ResourceHostMsg_Request; struct ViewMsg_ClosePage_Params; namespace net { @@ -384,12 +384,12 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate { void OnRequestResource(const IPC::Message& msg, int request_id, - const ViewHostMsg_Resource_Request& request_data); + const ResourceHostMsg_Request& request_data); void OnSyncLoad(int request_id, - const ViewHostMsg_Resource_Request& request_data, + const ResourceHostMsg_Request& request_data, IPC::Message* sync_result); void BeginRequest(int request_id, - const ViewHostMsg_Resource_Request& request_data, + const ResourceHostMsg_Request& request_data, IPC::Message* sync_result, // only valid for sync int route_id); // only valid for async void OnDataReceivedACK(int request_id); diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 6c3813e..e763523 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -10,13 +10,14 @@ #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" -#include "chrome/common/resource_response.h" #include "content/browser/browser_thread.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/renderer_host/resource_handler.h" #include "content/browser/renderer_host/resource_message_filter.h" +#include "content/common/resource_messages.h" +#include "content/common/resource_response.h" #include "net/base/net_errors.h" #include "net/base/upload_data.h" #include "net/http/http_util.h" @@ -37,7 +38,7 @@ void GetResponseHead(const std::vector<IPC::Message>& messages, ASSERT_GE(messages.size(), 2U); // The first messages should be received response. - ASSERT_EQ(ViewMsg_Resource_ReceivedResponse::ID, messages[0].type()); + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, messages[0].type()); void* iter = NULL; int request_id; @@ -50,22 +51,22 @@ void GetResponseHead(const std::vector<IPC::Message>& messages, static int RequestIDForMessage(const IPC::Message& msg) { int request_id = -1; switch (msg.type()) { - case ViewMsg_Resource_UploadProgress::ID: - case ViewMsg_Resource_ReceivedResponse::ID: - case ViewMsg_Resource_ReceivedRedirect::ID: - case ViewMsg_Resource_DataReceived::ID: - case ViewMsg_Resource_RequestComplete::ID: + case ResourceMsg_UploadProgress::ID: + case ResourceMsg_ReceivedResponse::ID: + case ResourceMsg_ReceivedRedirect::ID: + case ResourceMsg_DataReceived::ID: + case ResourceMsg_RequestComplete::ID: request_id = IPC::MessageIterator(msg).NextInt(); break; } return request_id; } -static ViewHostMsg_Resource_Request CreateResourceRequest( +static ResourceHostMsg_Request CreateResourceRequest( const char* method, ResourceType::Type type, const GURL& url) { - ViewHostMsg_Resource_Request request; + ResourceHostMsg_Request request; request.method = std::string(method); request.url = url; request.first_party_for_cookies = url; // bypass third-party cookie blocking @@ -285,9 +286,9 @@ void ResourceDispatcherHostTest::MakeTestRequest( int render_view_id, int request_id, const GURL& url) { - ViewHostMsg_Resource_Request request = + ResourceHostMsg_Request request = CreateResourceRequest("GET", resource_type_, url); - ViewHostMsg_RequestResource msg(render_view_id, request_id, request); + ResourceHostMsg_RequestResource msg(render_view_id, request_id, request); bool msg_was_ok; host_.OnMessageReceived(msg, filter, &msg_was_ok); KickOffRequest(); @@ -310,11 +311,11 @@ void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages, ASSERT_EQ(3U, messages.size()); // The first messages should be received response - ASSERT_EQ(ViewMsg_Resource_ReceivedResponse::ID, messages[0].type()); + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, messages[0].type()); // followed by the data, currently we only do the data in one chunk, but // should probably test multiple chunks later - ASSERT_EQ(ViewMsg_Resource_DataReceived::ID, messages[1].type()); + ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[1].type()); void* iter = NULL; int request_id; @@ -331,10 +332,10 @@ void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages, ASSERT_EQ(0, memcmp(reference_data.c_str(), data, data_len)); // followed by a 0-byte read - //ASSERT_EQ(ViewMsg_Resource_DataReceived::ID, messages[2].type()); + //ASSERT_EQ(ResourceMsg_DataReceived::ID, messages[2].type()); // the last message should be all data received - ASSERT_EQ(ViewMsg_Resource_RequestComplete::ID, messages[2].type()); + ASSERT_EQ(ResourceMsg_RequestComplete::ID, messages[2].type()); } // Tests whether many messages get dispatched properly. @@ -389,8 +390,8 @@ TEST_F(ResourceDispatcherHostTest, Cancel) { // Check that request 2 got canceled. ASSERT_EQ(2U, msgs[1].size()); - ASSERT_EQ(ViewMsg_Resource_ReceivedResponse::ID, msgs[1][0].type()); - ASSERT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[1][1].type()); + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type()); + ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type()); int request_id; net::URLRequestStatus status; @@ -429,7 +430,7 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) { scoped_refptr<TestFilter> test_filter = new TestFilter(); // request 1 goes to the test delegate - ViewHostMsg_Resource_Request request = CreateResourceRequest( + ResourceHostMsg_Request request = CreateResourceRequest( "GET", ResourceType::SUB_RESOURCE, net::URLRequestTestJob::test_url_1()); EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); @@ -758,7 +759,7 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) { // Should have sent a single RequestComplete message. int index = kMaxRequests + i; EXPECT_EQ(1U, msgs[index].size()); - EXPECT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[index][0].type()); + EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[index][0].type()); // The RequestComplete message should have had status // (CANCELLED, ERR_INSUFFICIENT_RESOURCES). @@ -922,7 +923,7 @@ TEST_F(ResourceDispatcherHostTest, ForbiddenDownload) { // We should have gotten one RequestComplete message. ASSERT_EQ(1U, msgs[0].size()); - EXPECT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[0][0].type()); + EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); // The RequestComplete message should have had status // (CANCELED, ERR_FILE_NOT_FOUND). diff --git a/content/browser/renderer_host/resource_message_filter.cc b/content/browser/renderer_host/resource_message_filter.cc index 7b3229b..3988776 100644 --- a/content/browser/renderer_host/resource_message_filter.cc +++ b/content/browser/renderer_host/resource_message_filter.cc @@ -36,7 +36,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message, } ChromeURLRequestContext* ResourceMessageFilter::GetURLRequestContext( - const ViewHostMsg_Resource_Request& resource_request) { + const ResourceHostMsg_Request& resource_request) { net::URLRequestContext* rv = NULL; if (url_request_context_override_.get()) rv = url_request_context_override_->GetRequestContext(resource_request); diff --git a/content/browser/renderer_host/resource_message_filter.h b/content/browser/renderer_host/resource_message_filter.h index 8873664..efc6aa0 100644 --- a/content/browser/renderer_host/resource_message_filter.h +++ b/content/browser/renderer_host/resource_message_filter.h @@ -11,7 +11,7 @@ class ChromeURLRequestContext; class ResourceDispatcherHost; -struct ViewHostMsg_Resource_Request; +struct ResourceHostMsg_Request; namespace net { class URLRequestContext; @@ -31,7 +31,7 @@ class ResourceMessageFilter : public BrowserMessageFilter { URLRequestContextOverride() {} virtual net::URLRequestContext* GetRequestContext( - const ViewHostMsg_Resource_Request& resource_request) = 0; + const ResourceHostMsg_Request& resource_request) = 0; protected: friend class base::RefCountedThreadSafe<URLRequestContextOverride>; @@ -51,7 +51,7 @@ class ResourceMessageFilter : public BrowserMessageFilter { // Returns the net::URLRequestContext for the given request. ChromeURLRequestContext* GetURLRequestContext( - const ViewHostMsg_Resource_Request& resource_request); + const ResourceHostMsg_Request& resource_request); void set_url_request_context_override(URLRequestContextOverride* u) { url_request_context_override_ = u; diff --git a/content/browser/renderer_host/socket_stream_dispatcher_host.cc b/content/browser/renderer_host/socket_stream_dispatcher_host.cc index d3c1b3a..ce6c855 100644 --- a/content/browser/renderer_host/socket_stream_dispatcher_host.cc +++ b/content/browser/renderer_host/socket_stream_dispatcher_host.cc @@ -11,6 +11,7 @@ #include "content/browser/renderer_host/socket_stream_host.h" #include "content/common/socket_stream.h" #include "content/common/socket_stream_messages.h" +#include "content/common/resource_messages.h" #include "net/websockets/websocket_job.h" #include "net/websockets/websocket_throttle.h" @@ -154,7 +155,7 @@ net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() { // GetRequestContext will take a different parameter and we can take out // this struct and the #include "chrome/common/render_messages_params.h" // above. - ViewHostMsg_Resource_Request request; + ResourceHostMsg_Request request; rv = url_request_context_override_->GetRequestContext(request); } if (!rv) { diff --git a/content/browser/renderer_host/sync_resource_handler.cc b/content/browser/renderer_host/sync_resource_handler.cc index 1b9a8f6..7b19a08 100644 --- a/content/browser/renderer_host/sync_resource_handler.cc +++ b/content/browser/renderer_host/sync_resource_handler.cc @@ -11,6 +11,7 @@ #include "content/browser/renderer_host/global_request_id.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_message_filter.h" +#include "content/common/resource_messages.h" #include "net/base/io_buffer.h" #include "net/http/http_response_headers.h" @@ -102,7 +103,7 @@ bool SyncResourceHandler::OnResponseCompleted( const std::string& security_info) { result_.status = status; - ViewHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); + ResourceHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); filter_->Send(result_message_); result_message_ = NULL; return true; diff --git a/content/browser/renderer_host/sync_resource_handler.h b/content/browser/renderer_host/sync_resource_handler.h index 95e8bfe..c07064c 100644 --- a/content/browser/renderer_host/sync_resource_handler.h +++ b/content/browser/renderer_host/sync_resource_handler.h @@ -9,7 +9,7 @@ #include <string> #include "content/browser/renderer_host/resource_handler.h" -#include "chrome/common/resource_response.h" +#include "content/common/resource_response.h" class ResourceDispatcherHost; class ResourceMessageFilter; diff --git a/content/browser/renderer_host/x509_user_cert_resource_handler.cc b/content/browser/renderer_host/x509_user_cert_resource_handler.cc index 7393e73..188538d 100644 --- a/content/browser/renderer_host/x509_user_cert_resource_handler.cc +++ b/content/browser/renderer_host/x509_user_cert_resource_handler.cc @@ -7,10 +7,10 @@ #include "base/string_util.h" #include "chrome/browser/download/download_types.h" #include "chrome/browser/ssl/ssl_add_cert_handler.h" -#include "chrome/common/resource_response.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" +#include "content/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" #include "net/base/mime_util.h" diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index 0a38d50..dfc90ae 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -55,7 +55,7 @@ class URLRequestContextOverride virtual ~URLRequestContextOverride() {} virtual net::URLRequestContext* GetRequestContext( - const ViewHostMsg_Resource_Request& resource_request) { + const ResourceHostMsg_Request& resource_request) { return url_request_context_; } diff --git a/content/common/common_param_traits.cc b/content/common/common_param_traits.cc index d25cb5b..fe92765 100644 --- a/content/common/common_param_traits.cc +++ b/content/common/common_param_traits.cc @@ -5,6 +5,10 @@ #include "content/common/common_param_traits.h" #include "content/common/content_constants.h" +#include "net/base/host_port_pair.h" +#include "net/base/upload_data.h" +#include "net/http/http_response_headers.h" +#include "webkit/glue/resource_loader_bridge.h" namespace IPC { @@ -27,4 +31,400 @@ void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { l->append(p.spec()); } + +void ParamTraits<ResourceType::Type>::Write(Message* m, const param_type& p) { + m->WriteInt(p); +} + +bool ParamTraits<ResourceType::Type>::Read(const Message* m, + void** iter, + param_type* p) { + int type; + if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) + return false; + *p = ResourceType::FromInt(type); + return true; +} + +void ParamTraits<ResourceType::Type>::Log(const param_type& p, std::string* l) { + std::string type; + switch (p) { + case ResourceType::MAIN_FRAME: + type = "MAIN_FRAME"; + break; + case ResourceType::SUB_FRAME: + type = "SUB_FRAME"; + break; + case ResourceType::SUB_RESOURCE: + type = "SUB_RESOURCE"; + break; + case ResourceType::OBJECT: + type = "OBJECT"; + break; + case ResourceType::MEDIA: + type = "MEDIA"; + break; + default: + type = "UNKNOWN"; + break; + } + + LogParam(type, l); +} + +void ParamTraits<net::URLRequestStatus>::Write(Message* m, + const param_type& p) { + WriteParam(m, static_cast<int>(p.status())); + WriteParam(m, p.os_error()); +} + +bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, void** iter, + param_type* r) { + int status, os_error; + if (!ReadParam(m, iter, &status) || + !ReadParam(m, iter, &os_error)) + return false; + r->set_status(static_cast<net::URLRequestStatus::Status>(status)); + r->set_os_error(os_error); + return true; +} + +void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, + std::string* l) { + std::string status; + switch (p.status()) { + case net::URLRequestStatus::SUCCESS: + status = "SUCCESS"; + break; + case net::URLRequestStatus::IO_PENDING: + status = "IO_PENDING "; + break; + case net::URLRequestStatus::HANDLED_EXTERNALLY: + status = "HANDLED_EXTERNALLY"; + break; + case net::URLRequestStatus::CANCELED: + status = "CANCELED"; + break; + case net::URLRequestStatus::FAILED: + status = "FAILED"; + break; + default: + status = "UNKNOWN"; + break; + } + if (p.status() == net::URLRequestStatus::FAILED) + l->append("("); + + LogParam(status, l); + + if (p.status() == net::URLRequestStatus::FAILED) { + l->append(", "); + LogParam(p.os_error(), l); + l->append(")"); + } +} + +// Only the net::UploadData ParamTraits<> definition needs this definition, so +// keep this in the implementation file so we can forward declare UploadData in +// the header. +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())); + switch (p.type()) { + case net::UploadData::TYPE_BYTES: { + m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); + break; + } + case net::UploadData::TYPE_CHUNK: { + std::string chunk_length = StringPrintf( + "%X\r\n", static_cast<unsigned int>(p.bytes().size())); + std::vector<char> bytes; + bytes.insert(bytes.end(), chunk_length.data(), + chunk_length.data() + chunk_length.length()); + const char* data = &p.bytes()[0]; + bytes.insert(bytes.end(), data, data + p.bytes().size()); + const char* crlf = "\r\n"; + bytes.insert(bytes.end(), crlf, crlf + strlen(crlf)); + if (p.is_last_chunk()) { + const char* end_of_data = "0\r\n\r\n"; + bytes.insert(bytes.end(), end_of_data, + end_of_data + strlen(end_of_data)); + } + m->WriteData(&bytes[0], static_cast<int>(bytes.size())); + // If this element is part of a chunk upload then send over information + // indicating if this is the last chunk. + WriteParam(m, p.is_last_chunk()); + break; + } + case 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()); + break; + } + default: { + WriteParam(m, p.blob_url()); + break; + } + } + } + static bool Read(const Message* m, void** iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type)) + return false; + switch (type) { + case net::UploadData::TYPE_BYTES: { + const char* data; + int len; + if (!m->ReadData(iter, &data, &len)) + return false; + r->SetToBytes(data, len); + break; + } + case net::UploadData::TYPE_CHUNK: { + const char* data; + int len; + if (!m->ReadData(iter, &data, &len)) + return false; + r->SetToBytes(data, len); + // If this element is part of a chunk upload then we need to explicitly + // set the type of the element and whether it is the last chunk. + bool is_last_chunk = false; + if (!ReadParam(m, iter, &is_last_chunk)) + return false; + r->set_type(net::UploadData::TYPE_CHUNK); + r->set_is_last_chunk(is_last_chunk); + break; + } + case net::UploadData::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->SetToFilePathRange(file_path, offset, length, + expected_modification_time); + break; + } + default: { + DCHECK(type == net::UploadData::TYPE_BLOB); + GURL blob_url; + if (!ReadParam(m, iter, &blob_url)) + return false; + r->SetToBlobUrl(blob_url); + break; + } + } + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append("<net::UploadData::Element>"); + } +}; + +void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, + const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p) { + WriteParam(m, *p->elements()); + WriteParam(m, p->identifier()); + WriteParam(m, p->is_chunked()); + } +} + +bool ParamTraits<scoped_refptr<net::UploadData> >::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; + int64 identifier; + if (!ReadParam(m, iter, &identifier)) + return false; + bool is_chunked = false; + if (!ReadParam(m, iter, &is_chunked)) + return false; + *r = new net::UploadData; + (*r)->swap_elements(&elements); + (*r)->set_identifier(identifier); + (*r)->set_is_chunked(is_chunked); + return true; +} + +void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, + std::string* l) { + l->append("<net::UploadData>"); +} + +void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { + WriteParam(m, p.host()); + WriteParam(m, p.port()); +} + +bool ParamTraits<net::HostPortPair>::Read(const Message* m, void** iter, + param_type* r) { + std::string host; + uint16 port; + if (!ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) + return false; + + r->set_host(host); + r->set_port(port); + return true; +} + +void ParamTraits<net::HostPortPair>::Log(const param_type& p, std::string* l) { + l->append(p.ToString()); +} + +void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( + Message* m, const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p) { + // Do not disclose Set-Cookie headers over IPC. + p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); + } +} + +bool ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Read( + const Message* m, void** iter, param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (has_object) + *r = new net::HttpResponseHeaders(*m, iter); + return true; +} + +void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( + const param_type& p, std::string* l) { + l->append("<HttpResponseHeaders>"); +} + +void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write( + Message* m, const param_type& p) { + WriteParam(m, p.base_time.is_null()); + if (p.base_time.is_null()) + return; + WriteParam(m, p.base_time); + WriteParam(m, p.proxy_start); + WriteParam(m, p.proxy_end); + WriteParam(m, p.dns_start); + WriteParam(m, p.dns_end); + WriteParam(m, p.connect_start); + WriteParam(m, p.connect_end); + WriteParam(m, p.ssl_start); + WriteParam(m, p.ssl_end); + WriteParam(m, p.send_start); + WriteParam(m, p.send_end); + WriteParam(m, p.receive_headers_start); + WriteParam(m, p.receive_headers_end); +} + +bool ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Read( + const Message* m, void** iter, param_type* r) { + bool is_null; + if (!ReadParam(m, iter, &is_null)) + return false; + if (is_null) + return true; + + return + ReadParam(m, iter, &r->base_time) && + ReadParam(m, iter, &r->proxy_start) && + ReadParam(m, iter, &r->proxy_end) && + ReadParam(m, iter, &r->dns_start) && + ReadParam(m, iter, &r->dns_end) && + ReadParam(m, iter, &r->connect_start) && + ReadParam(m, iter, &r->connect_end) && + ReadParam(m, iter, &r->ssl_start) && + ReadParam(m, iter, &r->ssl_end) && + ReadParam(m, iter, &r->send_start) && + ReadParam(m, iter, &r->send_end) && + ReadParam(m, iter, &r->receive_headers_start) && + ReadParam(m, iter, &r->receive_headers_end); +} + +void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Log(const param_type& p, + std::string* l) { + l->append("("); + LogParam(p.base_time, l); + l->append(", "); + LogParam(p.proxy_start, l); + l->append(", "); + LogParam(p.proxy_end, l); + l->append(", "); + LogParam(p.dns_start, l); + l->append(", "); + LogParam(p.dns_end, l); + l->append(", "); + LogParam(p.connect_start, l); + l->append(", "); + LogParam(p.connect_end, l); + l->append(", "); + LogParam(p.ssl_start, l); + l->append(", "); + LogParam(p.ssl_end, l); + l->append(", "); + LogParam(p.send_start, l); + l->append(", "); + LogParam(p.send_end, l); + l->append(", "); + LogParam(p.receive_headers_start, l); + l->append(", "); + LogParam(p.receive_headers_end, l); + l->append(")"); +} + +void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Write( + Message* m, const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p.get()) { + WriteParam(m, p->http_status_code); + WriteParam(m, p->http_status_text); + WriteParam(m, p->request_headers); + WriteParam(m, p->response_headers); + } +} + +bool ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::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; + *r = new webkit_glue::ResourceDevToolsInfo(); + return + ReadParam(m, iter, &(*r)->http_status_code) && + ReadParam(m, iter, &(*r)->http_status_text) && + ReadParam(m, iter, &(*r)->request_headers) && + ReadParam(m, iter, &(*r)->response_headers); +} + +void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Log( + const param_type& p, std::string* l) { + l->append("("); + if (p) { + LogParam(p->request_headers, l); + l->append(", "); + LogParam(p->response_headers, l); + } + l->append(")"); +} + } // namespace IPC diff --git a/content/common/common_param_traits.h b/content/common/common_param_traits.h index 9717dcc..1ecb5bb 100644 --- a/content/common/common_param_traits.h +++ b/content/common/common_param_traits.h @@ -14,17 +14,34 @@ #define CONTENT_COMMON_COMMON_PARAM_TRAITS_H_ #pragma once +#include "base/ref_counted.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message_utils.h" +#include "net/url_request/url_request_status.h" // !!! WARNING: DO NOT ADD NEW WEBKIT DEPENDENCIES !!! // // That means don't add #includes to any file in 'webkit/' or // 'third_party/WebKit/'. Chrome Frame and NACL build parts of base/ and // content/common/ for a mini-library that doesn't depend on webkit. +// TODO(erg): The following headers are historical and only work because +// their definitions are inlined, which also needs to be fixed. +#include "webkit/glue/resource_type.h" + // Forward declarations. class GURL; +namespace net { +class HttpResponseHeaders; +class HostPortPair; +class UploadData; +} + +namespace webkit_glue { +struct ResourceDevToolsInfo; +struct ResourceLoadTimingInfo; +} + namespace IPC { template <> @@ -35,6 +52,62 @@ struct ParamTraits<GURL> { static void Log(const param_type& p, std::string* l); }; +template <> +struct ParamTraits<ResourceType::Type> { + typedef ResourceType::Type param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<net::URLRequestStatus> { + typedef net::URLRequestStatus param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<scoped_refptr<net::UploadData> > { + typedef scoped_refptr<net::UploadData> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template<> +struct ParamTraits<net::HostPortPair> { + typedef net::HostPortPair param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { + typedef scoped_refptr<net::HttpResponseHeaders> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> { + typedef webkit_glue::ResourceLoadTimingInfo param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { + typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + } // namespace IPC #endif // CONTENT_COMMON_COMMON_PARAM_TRAITS_H_ diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index bcda993..ac64b0d 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -5,4 +5,5 @@ // Multiply-included file, hence no include guard. #include "content/common/p2p_messages.h" +#include "content/common/resource_messages.h" #include "content/common/socket_stream_messages.h" diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h new file mode 100644 index 0000000..73b9f8a --- /dev/null +++ b/content/common/resource_messages.h @@ -0,0 +1,196 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// IPC messages for resource loading. +// Multiply-included message file, hence no include guard. + +#include "base/shared_memory.h" +#include "content/common/resource_response.h" +#include "ipc/ipc_message_macros.h" +#include "net/base/upload_data.h" + +namespace net { +class UploadData; +} + +#define IPC_MESSAGE_START ResourceMsgStart + +IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) + IPC_STRUCT_TRAITS_MEMBER(request_time) + IPC_STRUCT_TRAITS_MEMBER(response_time) + IPC_STRUCT_TRAITS_MEMBER(headers) + IPC_STRUCT_TRAITS_MEMBER(mime_type) + IPC_STRUCT_TRAITS_MEMBER(charset) + IPC_STRUCT_TRAITS_MEMBER(security_info) + IPC_STRUCT_TRAITS_MEMBER(content_length) + IPC_STRUCT_TRAITS_MEMBER(appcache_id) + IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url) + IPC_STRUCT_TRAITS_MEMBER(connection_id) + IPC_STRUCT_TRAITS_MEMBER(connection_reused) + IPC_STRUCT_TRAITS_MEMBER(load_timing) + IPC_STRUCT_TRAITS_MEMBER(devtools_info) + IPC_STRUCT_TRAITS_MEMBER(download_file_path) + IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy) + IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated) + IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available) + IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy) + IPC_STRUCT_TRAITS_MEMBER(socket_address) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(ResourceResponseHead) + IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) + IPC_STRUCT_TRAITS_MEMBER(status) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(SyncLoadResult) + IPC_STRUCT_TRAITS_PARENT(ResourceResponseHead) + IPC_STRUCT_TRAITS_MEMBER(final_url) + IPC_STRUCT_TRAITS_MEMBER(data) +IPC_STRUCT_TRAITS_END() + +// Parameters for a resource request. +IPC_STRUCT_BEGIN(ResourceHostMsg_Request) + // The request method: GET, POST, etc. + IPC_STRUCT_MEMBER(std::string, method) + + // The requested URL. + IPC_STRUCT_MEMBER(GURL, url) + + // Usually the URL of the document in the top-level window, which may be + // checked by the third-party cookie blocking policy. Leaving it empty may + // lead to undesired cookie blocking. Third-party cookie blocking can be + // bypassed by setting first_party_for_cookies = url, but this should ideally + // only be done if there really is no way to determine the correct value. + IPC_STRUCT_MEMBER(GURL, first_party_for_cookies) + + // The referrer to use (may be empty). + IPC_STRUCT_MEMBER(GURL, referrer) + + // Additional HTTP request headers. + IPC_STRUCT_MEMBER(std::string, headers) + + // net::URLRequest load flags (0 by default). + IPC_STRUCT_MEMBER(int, load_flags) + + // Process ID from which this request originated, or zero if it originated + // in the renderer itself. + IPC_STRUCT_MEMBER(int, origin_pid) + + // What this resource load is for (main frame, sub-frame, sub-resource, + // object). + IPC_STRUCT_MEMBER(ResourceType::Type, resource_type) + + // Used by plugin->browser requests to get the correct net::URLRequestContext. + IPC_STRUCT_MEMBER(uint32, request_context) + + // Indicates which frame (or worker context) the request is being loaded into, + // or kNoHostId. + IPC_STRUCT_MEMBER(int, appcache_host_id) + + // Optional upload data (may be null). + IPC_STRUCT_MEMBER(scoped_refptr<net::UploadData>, upload_data) + + IPC_STRUCT_MEMBER(bool, download_to_file) + + // True if the request was user initiated. + IPC_STRUCT_MEMBER(bool, has_user_gesture) + + // The following two members are specified if the request is initiated by + // a plugin like Gears. + + // Contains the id of the host renderer. + IPC_STRUCT_MEMBER(int, host_renderer_id) + + // Contains the id of the host render view. + IPC_STRUCT_MEMBER(int, host_render_view_id) +IPC_STRUCT_END() + +// Resource messages sent from the browser to the renderer. + +// Sent when the headers are available for a resource request. +IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, + int /* request_id */, + ResourceResponseHead) + +// Sent when cached metadata from a resource request is ready. +IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, + int /* request_id */, + std::vector<char> /* data */) + +// Sent as upload progress is being made. +IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress, + int /* request_id */, + int64 /* position */, + int64 /* size */) + +// Sent when the request has been redirected. The receiver is expected to +// respond with either a FollowRedirect message (if the redirect is to be +// followed) or a CancelRequest message (if it should not be followed). +IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, + int /* request_id */, + GURL /* new_url */, + ResourceResponseHead) + +// Sent when some data from a resource request is ready. The handle should +// already be mapped into the process that receives this message. +IPC_MESSAGE_ROUTED3(ResourceMsg_DataReceived, + int /* request_id */, + base::SharedMemoryHandle /* data */, + int /* data_len */) + +// Sent when some data from a resource request has been downloaded to +// file. This is only called in the 'download_to_file' case and replaces +// ResourceMsg_DataReceived in the call sequence in that case. +IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded, + int /* request_id */, + int /* data_len */) + +// Sent when the request has been completed. +IPC_MESSAGE_ROUTED4(ResourceMsg_RequestComplete, + int /* request_id */, + net::URLRequestStatus /* status */, + std::string /* security info */, + base::Time /* completion_time */) + +// Resource messages sent from the renderer to the browser. + +// Makes a resource request via the browser. +IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource, + int /* request_id */, + ResourceHostMsg_Request) + +// Cancels a resource request with the ID given as the parameter. +IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest, + int /* request_id */) + +// Follows a redirect that occured for the resource request with the ID given +// as the parameter. +IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect, + int /* request_id */, + bool /* has_new_first_party_for_cookies */, + GURL /* new_first_party_for_cookies */) + +// Makes a synchronous resource request via the browser. +IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, + int /* request_id */, + ResourceHostMsg_Request, + SyncLoadResult) + +// Sent when the renderer process is done processing a DataReceived +// message. +IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK, + int /* request_id */) + +// Sent when the renderer has processed a DataDownloaded message. +IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK, + int /* request_id */) + +// Sent by the renderer process to acknowledge receipt of a +// UploadProgress message. +IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK, + int /* request_id */) + +// Sent when the renderer process deletes a resource loader. +IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile, + int /* request_id */) diff --git a/content/common/resource_response.h b/content/common/resource_response.h new file mode 100644 index 0000000..e58e106 --- /dev/null +++ b/content/common/resource_response.h @@ -0,0 +1,41 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// See http://dev.chromium.org/developers/design-documents/multi-process-resource-loading + +#ifndef CONTENT_COMMON_RESOURCE_RESPONSE_H_ +#define CONTENT_COMMON_RESOURCE_RESPONSE_H_ +#pragma once + +#include <string> + +#include "base/ref_counted.h" +#include "googleurl/src/gurl.h" +#include "net/url_request/url_request_status.h" +#include "webkit/glue/resource_loader_bridge.h" + +// Parameters for a resource response header. +struct ResourceResponseHead : webkit_glue::ResourceResponseInfo { + // The response status. + net::URLRequestStatus status; +}; + +// Parameters for a synchronous resource response. +struct SyncLoadResult : ResourceResponseHead { + // The final URL after any redirects. + GURL final_url; + + // The response data. + std::string data; +}; + +// Simple wrapper that refcounts ResourceResponseHead. +struct ResourceResponse : public base::RefCounted<ResourceResponse> { + ResourceResponseHead response_head; + + private: + friend class base::RefCounted<ResourceResponse>; +}; + +#endif // CONTENT_COMMON_RESOURCE_RESPONSE_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index 8b8753e..dc430e7e 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -27,6 +27,8 @@ 'common/p2p_messages.h', 'common/p2p_sockets.cc', 'common/p2p_sockets.h', + 'common/resource_messages.h', + 'common/resource_response.h', 'common/socket_stream.h', 'common/socket_stream_messages.h', ], |