Commit f465319a authored by jam@chromium.org's avatar jam@chromium.org

Convert a bunch of resource IPCs to be control messages. They didn't need to be routed.

BUG=286074
R=ajwong@chromium.org

Review URL: https://codereview.chromium.org/23583039

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221751 0039d316-1c4b-4281-b951-d872f2087c98
parent b926d6a8
...@@ -78,12 +78,10 @@ class DependentIOBuffer : public net::WrappedIOBuffer { ...@@ -78,12 +78,10 @@ class DependentIOBuffer : public net::WrappedIOBuffer {
AsyncResourceHandler::AsyncResourceHandler( AsyncResourceHandler::AsyncResourceHandler(
ResourceMessageFilter* filter, ResourceMessageFilter* filter,
int routing_id,
net::URLRequest* request, net::URLRequest* request,
ResourceDispatcherHostImpl* rdh) ResourceDispatcherHostImpl* rdh)
: ResourceMessageDelegate(request), : ResourceMessageDelegate(request),
filter_(filter), filter_(filter),
routing_id_(routing_id),
request_(request), request_(request),
rdh_(rdh), rdh_(rdh),
pending_data_count_(0), pending_data_count_(0),
...@@ -139,8 +137,8 @@ void AsyncResourceHandler::OnDataReceivedACK(int request_id) { ...@@ -139,8 +137,8 @@ void AsyncResourceHandler::OnDataReceivedACK(int request_id) {
bool AsyncResourceHandler::OnUploadProgress(int request_id, bool AsyncResourceHandler::OnUploadProgress(int request_id,
uint64 position, uint64 position,
uint64 size) { uint64 size) {
return filter_->Send(new ResourceMsg_UploadProgress(routing_id_, request_id, return filter_->Send(new ResourceMsg_UploadProgress(request_id, position,
position, size)); size));
} }
bool AsyncResourceHandler::OnRequestRedirected(int request_id, bool AsyncResourceHandler::OnRequestRedirected(int request_id,
...@@ -159,7 +157,7 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id, ...@@ -159,7 +157,7 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id,
response->head.request_start = request_->creation_time(); response->head.request_start = request_->creation_time();
response->head.response_start = TimeTicks::Now(); response->head.response_start = TimeTicks::Now();
return filter_->Send(new ResourceMsg_ReceivedRedirect( return filter_->Send(new ResourceMsg_ReceivedRedirect(
routing_id_, request_id, new_url, response->head)); request_id, new_url, response->head));
} }
bool AsyncResourceHandler::OnResponseStarted(int request_id, bool AsyncResourceHandler::OnResponseStarted(int request_id,
...@@ -194,16 +192,14 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, ...@@ -194,16 +192,14 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id,
response->head.request_start = request_->creation_time(); response->head.request_start = request_->creation_time();
response->head.response_start = TimeTicks::Now(); response->head.response_start = TimeTicks::Now();
filter_->Send(new ResourceMsg_ReceivedResponse( filter_->Send(new ResourceMsg_ReceivedResponse(request_id, response->head));
routing_id_, request_id, response->head));
sent_received_response_msg_ = true; sent_received_response_msg_ = true;
if (request_->response_info().metadata.get()) { if (request_->response_info().metadata.get()) {
std::vector<char> copy(request_->response_info().metadata->data(), std::vector<char> copy(request_->response_info().metadata->data(),
request_->response_info().metadata->data() + request_->response_info().metadata->data() +
request_->response_info().metadata->size()); request_->response_info().metadata->size());
filter_->Send(new ResourceMsg_ReceivedCachedMetadata( filter_->Send(new ResourceMsg_ReceivedCachedMetadata(request_id, copy));
routing_id_, request_id, copy));
} }
return true; return true;
...@@ -254,9 +250,8 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, ...@@ -254,9 +250,8 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read,
int size; int size;
if (!buffer_->ShareToProcess(filter_->PeerHandle(), &handle, &size)) if (!buffer_->ShareToProcess(filter_->PeerHandle(), &handle, &size))
return false; return false;
filter_->Send( filter_->Send(new ResourceMsg_SetDataBuffer(
new ResourceMsg_SetDataBuffer(routing_id_, request_id, handle, size, request_id, handle, size, filter_->peer_pid()));
filter_->peer_pid()));
sent_first_data_msg_ = true; sent_first_data_msg_ = true;
} }
...@@ -264,9 +259,8 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, ...@@ -264,9 +259,8 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read,
int encoded_data_length = int encoded_data_length =
DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_); DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_);
filter_->Send( filter_->Send(new ResourceMsg_DataReceived(
new ResourceMsg_DataReceived(routing_id_, request_id, data_offset, request_id, data_offset, bytes_read, encoded_data_length));
bytes_read, encoded_data_length));
++pending_data_count_; ++pending_data_count_;
UMA_HISTOGRAM_CUSTOM_COUNTS( UMA_HISTOGRAM_CUSTOM_COUNTS(
"Net.AsyncResourceHandler_PendingDataCount", "Net.AsyncResourceHandler_PendingDataCount",
...@@ -288,7 +282,7 @@ void AsyncResourceHandler::OnDataDownloaded( ...@@ -288,7 +282,7 @@ void AsyncResourceHandler::OnDataDownloaded(
DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_); DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_);
filter_->Send(new ResourceMsg_DataDownloaded( filter_->Send(new ResourceMsg_DataDownloaded(
routing_id_, request_id, bytes_downloaded, encoded_data_length)); request_id, bytes_downloaded, encoded_data_length));
} }
bool AsyncResourceHandler::OnResponseCompleted( bool AsyncResourceHandler::OnResponseCompleted(
...@@ -331,8 +325,7 @@ bool AsyncResourceHandler::OnResponseCompleted( ...@@ -331,8 +325,7 @@ bool AsyncResourceHandler::OnResponseCompleted(
error_code = net::ERR_FAILED; error_code = net::ERR_FAILED;
} }
filter_->Send(new ResourceMsg_RequestComplete(routing_id_, filter_->Send(new ResourceMsg_RequestComplete(request_id,
request_id,
error_code, error_code,
was_ignored_by_handler, was_ignored_by_handler,
security_info, security_info,
......
...@@ -28,7 +28,6 @@ class AsyncResourceHandler : public ResourceHandler, ...@@ -28,7 +28,6 @@ class AsyncResourceHandler : public ResourceHandler,
public ResourceMessageDelegate { public ResourceMessageDelegate {
public: public:
AsyncResourceHandler(ResourceMessageFilter* filter, AsyncResourceHandler(ResourceMessageFilter* filter,
int routing_id,
net::URLRequest* request, net::URLRequest* request,
ResourceDispatcherHostImpl* rdh); ResourceDispatcherHostImpl* rdh);
virtual ~AsyncResourceHandler(); virtual ~AsyncResourceHandler();
...@@ -75,7 +74,6 @@ class AsyncResourceHandler : public ResourceHandler, ...@@ -75,7 +74,6 @@ class AsyncResourceHandler : public ResourceHandler,
scoped_refptr<ResourceBuffer> buffer_; scoped_refptr<ResourceBuffer> buffer_;
scoped_refptr<ResourceMessageFilter> filter_; scoped_refptr<ResourceMessageFilter> filter_;
int routing_id_;
net::URLRequest* request_; net::URLRequest* request_;
ResourceDispatcherHostImpl* rdh_; ResourceDispatcherHostImpl* rdh_;
......
...@@ -138,7 +138,6 @@ const int kAllNetErrorCodes[] = { ...@@ -138,7 +138,6 @@ const int kAllNetErrorCodes[] = {
// Aborts a request before an URLRequest has actually been created. // Aborts a request before an URLRequest has actually been created.
void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, void AbortRequestBeforeItStarts(ResourceMessageFilter* filter,
IPC::Message* sync_result, IPC::Message* sync_result,
int route_id,
int request_id) { int request_id) {
if (sync_result) { if (sync_result) {
SyncLoadResult result; SyncLoadResult result;
...@@ -148,7 +147,6 @@ void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, ...@@ -148,7 +147,6 @@ void AbortRequestBeforeItStarts(ResourceMessageFilter* filter,
} else { } else {
// Tell the renderer that this request was disallowed. // Tell the renderer that this request was disallowed.
filter->Send(new ResourceMsg_RequestComplete( filter->Send(new ResourceMsg_RequestComplete(
route_id,
request_id, request_id,
net::ERR_ABORTED, net::ERR_ABORTED,
false, false,
...@@ -929,7 +927,7 @@ void ResourceDispatcherHostImpl::BeginRequest( ...@@ -929,7 +927,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
if (is_shutdown_ || if (is_shutdown_ ||
!ShouldServiceRequest(process_type, child_id, request_data, !ShouldServiceRequest(process_type, child_id, request_data,
filter_->file_system_context())) { filter_->file_system_context())) {
AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); AbortRequestBeforeItStarts(filter_, sync_result, request_id);
return; return;
} }
...@@ -942,7 +940,7 @@ void ResourceDispatcherHostImpl::BeginRequest( ...@@ -942,7 +940,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
request_data.url, request_data.url,
request_data.resource_type, request_data.resource_type,
resource_context)) { resource_context)) {
AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); AbortRequestBeforeItStarts(filter_, sync_result, request_id);
return; return;
} }
...@@ -1041,8 +1039,7 @@ void ResourceDispatcherHostImpl::BeginRequest( ...@@ -1041,8 +1039,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
handler.reset(new SyncResourceHandler( handler.reset(new SyncResourceHandler(
filter_, request, sync_result, this)); filter_, request, sync_result, this));
} else { } else {
handler.reset(new AsyncResourceHandler( handler.reset(new AsyncResourceHandler(filter_, request, this));
filter_, route_id, request, this));
} }
// The RedirectToFileResourceHandler depends on being next in the chain. // The RedirectToFileResourceHandler depends on being next in the chain.
......
...@@ -708,7 +708,7 @@ class ResourceDispatcherHostTest : public testing::Test, ...@@ -708,7 +708,7 @@ class ResourceDispatcherHostTest : public testing::Test,
bool result = PickleIterator(msg).ReadInt(&request_id); bool result = PickleIterator(msg).ReadInt(&request_id);
DCHECK(result); DCHECK(result);
scoped_ptr<IPC::Message> ack( scoped_ptr<IPC::Message> ack(
new ResourceHostMsg_DataReceived_ACK(msg.routing_id(), request_id)); new ResourceHostMsg_DataReceived_ACK(request_id));
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
FROM_HERE, FROM_HERE,
...@@ -1609,7 +1609,7 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { ...@@ -1609,7 +1609,7 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
// And now simulate a cancellation coming from the renderer. // And now simulate a cancellation coming from the renderer.
ResourceHostMsg_CancelRequest msg(filter_->child_id(), request_id); ResourceHostMsg_CancelRequest msg(request_id);
bool msg_was_ok; bool msg_was_ok;
host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
...@@ -1644,7 +1644,7 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) { ...@@ -1644,7 +1644,7 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
// And now simulate a cancellation coming from the renderer. // And now simulate a cancellation coming from the renderer.
ResourceHostMsg_CancelRequest msg(filter_->child_id(), request_id); ResourceHostMsg_CancelRequest msg(request_id);
bool msg_was_ok; bool msg_was_ok;
host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
...@@ -1685,7 +1685,7 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) { ...@@ -1685,7 +1685,7 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
GURL("http://example.com/blah")); GURL("http://example.com/blah"));
// And now simulate a cancellation coming from the renderer. // And now simulate a cancellation coming from the renderer.
ResourceHostMsg_CancelRequest msg(filter_->child_id(), request_id); ResourceHostMsg_CancelRequest msg(request_id);
bool msg_was_ok; bool msg_was_ok;
host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
...@@ -1832,7 +1832,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationAndThenRedirect) { ...@@ -1832,7 +1832,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationAndThenRedirect) {
// Now, simulate the renderer choosing to follow the redirect. // Now, simulate the renderer choosing to follow the redirect.
ResourceHostMsg_FollowRedirect redirect_msg( ResourceHostMsg_FollowRedirect redirect_msg(
new_render_view_id, new_request_id, false, GURL()); new_request_id, false, GURL());
host_.OnMessageReceived(redirect_msg, second_filter.get(), &msg_was_ok); host_.OnMessageReceived(redirect_msg, second_filter.get(), &msg_was_ok);
base::MessageLoop::current()->RunUntilIdle(); base::MessageLoop::current()->RunUntilIdle();
...@@ -1938,7 +1938,7 @@ TEST_F(ResourceDispatcherHostTest, DelayedDataReceivedACKs) { ...@@ -1938,7 +1938,7 @@ TEST_F(ResourceDispatcherHostTest, DelayedDataReceivedACKs) {
EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type());
ResourceHostMsg_DataReceived_ACK msg(0, 1); ResourceHostMsg_DataReceived_ACK msg(1);
bool msg_was_ok; bool msg_was_ok;
host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
} }
...@@ -1973,7 +1973,7 @@ TEST_F(ResourceDispatcherHostTest, DataReceivedUnexpectedACKs) { ...@@ -1973,7 +1973,7 @@ TEST_F(ResourceDispatcherHostTest, DataReceivedUnexpectedACKs) {
// Send some unexpected ACKs. // Send some unexpected ACKs.
for (size_t i = 0; i < 128; ++i) { for (size_t i = 0; i < 128; ++i) {
ResourceHostMsg_DataReceived_ACK msg(0, 1); ResourceHostMsg_DataReceived_ACK msg(1);
bool msg_was_ok; bool msg_was_ok;
host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
} }
...@@ -1992,7 +1992,7 @@ TEST_F(ResourceDispatcherHostTest, DataReceivedUnexpectedACKs) { ...@@ -1992,7 +1992,7 @@ TEST_F(ResourceDispatcherHostTest, DataReceivedUnexpectedACKs) {
EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type());
ResourceHostMsg_DataReceived_ACK msg(0, 1); ResourceHostMsg_DataReceived_ACK msg(1);
bool msg_was_ok; bool msg_was_ok;
host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
} }
......
...@@ -193,8 +193,7 @@ class ResourceSchedulerTest : public testing::Test { ...@@ -193,8 +193,7 @@ class ResourceSchedulerTest : public testing::Test {
const ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest( const ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
request->url_request()); request->url_request());
const GlobalRequestID& id = info->GetGlobalRequestID(); const GlobalRequestID& id = info->GetGlobalRequestID();
ResourceHostMsg_DidChangePriority msg( ResourceHostMsg_DidChangePriority msg(id.request_id, new_priority);
kRouteId, id.request_id, new_priority);
bool ok = false; bool ok = false;
rdh_.OnMessageReceived(msg, filter.get(), &ok); rdh_.OnMessageReceived(msg, filter.get(), &ok);
EXPECT_TRUE(ok); EXPECT_TRUE(ok);
......
...@@ -1220,7 +1220,6 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { ...@@ -1220,7 +1220,6 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
// Adding single handlers for your service here is fine, but once your // Adding single handlers for your service here is fine, but once your
// service needs more than one handler, please extract them into a new // service needs more than one handler, please extract them into a new
// message filter and add that filter to CreateMessageFilters(). // message filter and add that filter to CreateMessageFilters().
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP_EX() IPC_END_MESSAGE_MAP_EX()
if (!msg_is_ok) { if (!msg_is_ok) {
......
...@@ -200,7 +200,7 @@ void IPCResourceLoaderBridge::Cancel() { ...@@ -200,7 +200,7 @@ void IPCResourceLoaderBridge::Cancel() {
} }
if (!is_synchronous_request_) if (!is_synchronous_request_)
dispatcher_->CancelPendingRequest(routing_id_, request_id_); dispatcher_->CancelPendingRequest(request_id_);
// We can't remove the request ID from the resource dispatcher because more // We can't remove the request ID from the resource dispatcher because more
// data might be pending. Sending the cancel message may cause more data // data might be pending. Sending the cancel message may cause more data
...@@ -324,8 +324,8 @@ ResourceDispatcher::GetPendingRequestInfo(int request_id) { ...@@ -324,8 +324,8 @@ ResourceDispatcher::GetPendingRequestInfo(int request_id) {
return &(it->second); return &(it->second);
} }
void ResourceDispatcher::OnUploadProgress( void ResourceDispatcher::OnUploadProgress(int request_id, int64 position,
const IPC::Message& message, int request_id, int64 position, int64 size) { int64 size) {
PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
if (!request_info) if (!request_info)
return; return;
...@@ -333,8 +333,7 @@ void ResourceDispatcher::OnUploadProgress( ...@@ -333,8 +333,7 @@ void ResourceDispatcher::OnUploadProgress(
request_info->peer->OnUploadProgress(position, size); request_info->peer->OnUploadProgress(position, size);
// Acknowledge receipt // Acknowledge receipt
message_sender()->Send( message_sender()->Send(new ResourceHostMsg_UploadProgress_ACK(request_id));
new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id));
} }
void ResourceDispatcher::OnReceivedResponse( void ResourceDispatcher::OnReceivedResponse(
...@@ -373,8 +372,7 @@ void ResourceDispatcher::OnReceivedCachedMetadata( ...@@ -373,8 +372,7 @@ void ResourceDispatcher::OnReceivedCachedMetadata(
request_info->peer->OnReceivedCachedMetadata(&data.front(), data.size()); request_info->peer->OnReceivedCachedMetadata(&data.front(), data.size());
} }
void ResourceDispatcher::OnSetDataBuffer(const IPC::Message& message, void ResourceDispatcher::OnSetDataBuffer(int request_id,
int request_id,
base::SharedMemoryHandle shm_handle, base::SharedMemoryHandle shm_handle,
int shm_size, int shm_size,
base::ProcessId renderer_pid) { base::ProcessId renderer_pid) {
...@@ -404,8 +402,7 @@ void ResourceDispatcher::OnSetDataBuffer(const IPC::Message& message, ...@@ -404,8 +402,7 @@ void ResourceDispatcher::OnSetDataBuffer(const IPC::Message& message,
request_info->buffer_size = shm_size; request_info->buffer_size = shm_size;
} }
void ResourceDispatcher::OnReceivedData(const IPC::Message& message, void ResourceDispatcher::OnReceivedData(int request_id,
int request_id,
int data_offset, int data_offset,
int data_length, int data_length,
int encoded_data_length) { int encoded_data_length) {
...@@ -449,17 +446,15 @@ void ResourceDispatcher::OnReceivedData(const IPC::Message& message, ...@@ -449,17 +446,15 @@ void ResourceDispatcher::OnReceivedData(const IPC::Message& message,
} }
// Acknowledge the reception of this data. // Acknowledge the reception of this data.
message_sender()->Send( message_sender()->Send(new ResourceHostMsg_DataReceived_ACK(request_id));
new ResourceHostMsg_DataReceived_ACK(message.routing_id(), request_id));
} }
void ResourceDispatcher::OnDownloadedData(const IPC::Message& message, void ResourceDispatcher::OnDownloadedData(int request_id,
int request_id,
int data_len, int data_len,
int encoded_data_length) { int encoded_data_length) {
// Acknowledge the reception of this message. // Acknowledge the reception of this message.
message_sender()->Send( message_sender()->Send(
new ResourceHostMsg_DataDownloaded_ACK(message.routing_id(), request_id)); new ResourceHostMsg_DataDownloaded_ACK(request_id));
PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
if (!request_info) if (!request_info)
...@@ -469,7 +464,6 @@ void ResourceDispatcher::OnDownloadedData(const IPC::Message& message, ...@@ -469,7 +464,6 @@ void ResourceDispatcher::OnDownloadedData(const IPC::Message& message,
} }
void ResourceDispatcher::OnReceivedRedirect( void ResourceDispatcher::OnReceivedRedirect(
const IPC::Message& message,
int request_id, int request_id,
const GURL& new_url, const GURL& new_url,
const ResourceResponseHead& response_head) { const ResourceResponseHead& response_head) {
...@@ -478,7 +472,6 @@ void ResourceDispatcher::OnReceivedRedirect( ...@@ -478,7 +472,6 @@ void ResourceDispatcher::OnReceivedRedirect(
return; return;
request_info->response_start = ConsumeIOTimestamp(); request_info->response_start = ConsumeIOTimestamp();
int32 routing_id = message.routing_id();
bool has_new_first_party_for_cookies = false; bool has_new_first_party_for_cookies = false;
GURL new_first_party_for_cookies; GURL new_first_party_for_cookies;
ResourceResponseInfo renderer_response_info; ResourceResponseInfo renderer_response_info;
...@@ -495,14 +488,14 @@ void ResourceDispatcher::OnReceivedRedirect( ...@@ -495,14 +488,14 @@ void ResourceDispatcher::OnReceivedRedirect(
// SiteIsolationPolicy later when OnReceivedResponse is called. // SiteIsolationPolicy later when OnReceivedResponse is called.
request_info->response_url = new_url; request_info->response_url = new_url;
request_info->pending_redirect_message.reset( request_info->pending_redirect_message.reset(
new ResourceHostMsg_FollowRedirect(routing_id, request_id, new ResourceHostMsg_FollowRedirect(request_id,
has_new_first_party_for_cookies, has_new_first_party_for_cookies,
new_first_party_for_cookies)); new_first_party_for_cookies));
if (!request_info->is_deferred) { if (!request_info->is_deferred) {
FollowPendingRedirect(request_id, *request_info); FollowPendingRedirect(request_id, *request_info);
} }
} else { } else {
CancelPendingRequest(routing_id, request_id); CancelPendingRequest(request_id);
} }
} }
...@@ -574,8 +567,7 @@ bool ResourceDispatcher::RemovePendingRequest(int request_id) { ...@@ -574,8 +567,7 @@ bool ResourceDispatcher::RemovePendingRequest(int request_id) {
return true; return true;
} }
void ResourceDispatcher::CancelPendingRequest(int routing_id, void ResourceDispatcher::CancelPendingRequest(int request_id) {
int request_id) {
PendingRequestList::iterator it = pending_requests_.find(request_id); PendingRequestList::iterator it = pending_requests_.find(request_id);
if (it == pending_requests_.end()) { if (it == pending_requests_.end()) {
DVLOG(1) << "unknown request"; DVLOG(1) << "unknown request";
...@@ -587,8 +579,7 @@ void ResourceDispatcher::CancelPendingRequest(int routing_id, ...@@ -587,8 +579,7 @@ void ResourceDispatcher::CancelPendingRequest(int routing_id,
ReleaseResourcesInMessageQueue(&request_info.deferred_message_queue); ReleaseResourcesInMessageQueue(&request_info.deferred_message_queue);
pending_requests_.erase(it); pending_requests_.erase(it);
message_sender()->Send( message_sender()->Send(new ResourceHostMsg_CancelRequest(request_id));
new ResourceHostMsg_CancelRequest(routing_id, request_id));
} }
void ResourceDispatcher::SetDefersLoading(int request_id, bool value) { void ResourceDispatcher::SetDefersLoading(int request_id, bool value) {
...@@ -617,7 +608,7 @@ void ResourceDispatcher::DidChangePriority( ...@@ -617,7 +608,7 @@ void ResourceDispatcher::DidChangePriority(
int routing_id, int request_id, net::RequestPriority new_priority) { int routing_id, int request_id, net::RequestPriority new_priority) {
DCHECK(ContainsKey(pending_requests_, request_id)); DCHECK(ContainsKey(pending_requests_, request_id));
message_sender()->Send(new ResourceHostMsg_DidChangePriority( message_sender()->Send(new ResourceHostMsg_DidChangePriority(
routing_id, request_id, new_priority)); request_id, new_priority));
} }
ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() ResourceDispatcher::PendingRequestInfo::PendingRequestInfo()
......
...@@ -54,7 +54,7 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { ...@@ -54,7 +54,7 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener {
bool RemovePendingRequest(int request_id); bool RemovePendingRequest(int request_id);
// Cancels a request in the pending_requests_ list. // Cancels a request in the pending_requests_ list.
void CancelPendingRequest(int routing_id, int request_id); void CancelPendingRequest(int request_id);
IPC::Sender* message_sender() const { IPC::Sender* message_sender() const {
return message_sender_; return message_sender_;
...@@ -125,31 +125,26 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { ...@@ -125,31 +125,26 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener {
// Message response handlers, called by the message handler for this process. // Message response handlers, called by the message handler for this process.
void OnUploadProgress( void OnUploadProgress(
const IPC::Message& message,
int request_id, int request_id,
int64 position, int64 position,
int64 size); int64 size);
void OnReceivedResponse(int request_id, const ResourceResponseHead&); void OnReceivedResponse(int request_id, const ResourceResponseHead&);
void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data); void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data);
void OnReceivedRedirect( void OnReceivedRedirect(
const IPC::Message& message,
int request_id, int request_id,
const GURL& new_url, const GURL& new_url,
const ResourceResponseHead& response_head); const ResourceResponseHead& response_head);
void OnSetDataBuffer( void OnSetDataBuffer(
const IPC::Message& message,
int request_id, int request_id,
base::SharedMemoryHandle shm_handle, base::SharedMemoryHandle shm_handle,
int shm_size, int shm_size,
base::ProcessId renderer_pid); base::ProcessId renderer_pid);
void OnReceivedData( void OnReceivedData(
const IPC::Message& message,
int request_id, int request_id,
int data_offset, int data_offset,
int data_length, int data_length,
int encoded_data_length); int encoded_data_length);
void OnDownloadedData( void OnDownloadedData(
const IPC::Message& message,
int request_id, int request_id,
int data_len, int data_len,
int encoded_data_length); int encoded_data_length);
......
...@@ -134,10 +134,9 @@ class ResourceDispatcherTest : public testing::Test, public IPC::Sender { ...@@ -134,10 +134,9 @@ class ResourceDispatcherTest : public testing::Test, public IPC::Sender {
base::SharedMemoryHandle dup_handle; base::SharedMemoryHandle dup_handle;
EXPECT_TRUE(shared_mem.GiveToProcess( EXPECT_TRUE(shared_mem.GiveToProcess(
base::Process::Current().handle(), &dup_handle)); base::Process::Current().handle(), &dup_handle));
dispatcher_->OnSetDataBuffer(message_queue_[0], request_id, dup_handle, dispatcher_->OnSetDataBuffer(request_id, dup_handle,
test_page_contents_len, 0); test_page_contents_len, 0);
dispatcher_->OnReceivedData(message_queue_[0], request_id, 0, dispatcher_->OnReceivedData(request_id, 0, test_page_contents_len,
test_page_contents_len,
test_page_contents_len); test_page_contents_len);
message_queue_.erase(message_queue_.begin()); message_queue_.erase(message_queue_.begin());
...@@ -251,7 +250,7 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest, ...@@ -251,7 +250,7 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest,
response_head.error_code = net::OK; response_head.error_code = net::OK;
dispatcher_->OnMessageReceived( dispatcher_->OnMessageReceived(
ResourceMsg_ReceivedResponse(0, 0, response_head)); ResourceMsg_ReceivedResponse(0, response_head));
// Duplicate the shared memory handle so both the test and the callee can // Duplicate the shared memory handle so both the test and the callee can
// close their copy. // close their copy.
...@@ -260,9 +259,8 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest, ...@@ -260,9 +259,8 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest,
&duplicated_handle)); &duplicated_handle));
dispatcher_->OnMessageReceived( dispatcher_->OnMessageReceived(
ResourceMsg_SetDataBuffer(0, 0, duplicated_handle, 100, 0)); ResourceMsg_SetDataBuffer(0, duplicated_handle, 100, 0));
dispatcher_->OnMessageReceived( dispatcher_->OnMessageReceived(ResourceMsg_DataReceived(0, 0, 100, 100));
ResourceMsg_DataReceived(0, 0, 0, 100, 100));
set_defer_loading(false); set_defer_loading(false);
} }
...@@ -355,7 +353,7 @@ class TimeConversionTest : public ResourceDispatcherTest, ...@@ -355,7 +353,7 @@ class TimeConversionTest : public ResourceDispatcherTest,
bridge->Start(this); bridge->Start(this);
dispatcher_->OnMessageReceived( dispatcher_->OnMessageReceived(
ResourceMsg_ReceivedResponse(0, 0, response_head)); ResourceMsg_ReceivedResponse(0, response_head));
} }
// ResourceLoaderBridge::Peer methods. // ResourceLoaderBridge::Peer methods.
......
...@@ -203,28 +203,28 @@ IPC_STRUCT_END() ...@@ -203,28 +203,28 @@ IPC_STRUCT_END()
// Resource messages sent from the browser to the renderer. // Resource messages sent from the browser to the renderer.
// Sent when the headers are available for a resource request. // Sent when the headers are available for a resource request.
IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
int /* request_id */, int /* request_id */,
content::ResourceResponseHead) content::ResourceResponseHead)
// Sent when cached metadata from a resource request is ready. // Sent when cached metadata from a resource request is ready.
IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
int /* request_id */, int /* request_id */,
std::vector<char> /* data */) std::vector<char> /* data */)
// Sent as upload progress is being made. // Sent as upload progress is being made.
IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress, IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
int /* request_id */, int /* request_id */,
int64 /* position */, int64 /* position */,
int64 /* size */) int64 /* size */)
// Sent when the request has been redirected. The receiver is expected to // Sent when the request has been redirected. The receiver is expected to
// respond with either a FollowRedirect message (if the redirect is to be // respond with either a FollowRedirect message (if the redirect is to be
// followed) or a CancelRequest message (if it should not be followed). // followed) or a CancelRequest message (if it should not be followed).
IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, IPC_MESSAGE_CONTROL3(ResourceMsg_ReceivedRedirect,
int /* request_id */, int /* request_id */,
GURL /* new_url */, GURL /* new_url */,
content::ResourceResponseHead) content::ResourceResponseHead)
// Sent to set the shared memory buffer to be used to transmit response data to // Sent to set the shared memory buffer to be used to transmit response data to
// the renderer. Subsequent DataReceived messages refer to byte ranges in the // the renderer. Subsequent DataReceived messages refer to byte ranges in the
...@@ -237,36 +237,36 @@ IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, ...@@ -237,36 +237,36 @@ IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect,
// TODO(darin): The |renderer_pid| parameter is just a temporary parameter, // TODO(darin): The |renderer_pid| parameter is just a temporary parameter,
// added to help in debugging crbug/160401. // added to help in debugging crbug/160401.
// //
IPC_MESSAGE_ROUTED4(ResourceMsg_SetDataBuffer, IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
int /* request_id */, int /* request_id */,
base::SharedMemoryHandle /* shm_handle */, base::SharedMemoryHandle /* shm_handle */,
int /* shm_size */, int /* shm_size */,
base::ProcessId /* renderer_pid */) base::ProcessId /* renderer_pid */)
// Sent when some data from a resource request is ready. The data offset and // Sent when some data from a resource request is ready. The data offset and
// length specify a byte range into the shared memory buffer provided by the // length specify a byte range into the shared memory buffer provided by the
// SetDataBuffer message. // SetDataBuffer message.
IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived, IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceived,
int /* request_id */, int /* request_id */,
int /* data_offset */, int /* data_offset */,
int /* data_length */, int /* data_length */,
int /* encoded_data_length */) int /* encoded_data_length */)
// Sent when some data from a resource request has been downloaded to // 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 // file. This is only called in the 'download_to_file' case and replaces
// ResourceMsg_DataReceived in the call sequence in that case. // ResourceMsg_DataReceived in the call sequence in that case.
IPC_MESSAGE_ROUTED3(ResourceMsg_DataDownloaded, IPC_MESSAGE_CONTROL3(ResourceMsg_DataDownloaded,
int /* request_id */, int /* request_id */,
int /* data_len */, int /* data_len */,
int /* encoded_data_length */) int /* encoded_data_length */)
// Sent when the request has been completed. // Sent when the request has been completed.
IPC_MESSAGE_ROUTED5(ResourceMsg_RequestComplete, IPC_MESSAGE_CONTROL5(ResourceMsg_RequestComplete,
int /* request_id */, int /* request_id */,
int /* error_code */, int /* error_code */,
bool /* was_ignored_by_handler */, bool /* was_ignored_by_handler */,
std::string /* security info */, std::string /* security info */,
base::TimeTicks /* completion_time */) base::TimeTicks /* completion_time */)
// Resource messages sent from the renderer to the browser. // Resource messages sent from the renderer to the browser.
...@@ -276,15 +276,15 @@ IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource, ...@@ -276,15 +276,15 @@ IPC_MESSAGE_ROUTED2(ResourceHostMsg_RequestResource,
ResourceHostMsg_Request) ResourceHostMsg_Request)
// Cancels a resource request with the ID given as the parameter. // Cancels a resource request with the ID given as the parameter.
IPC_MESSAGE_ROUTED1(ResourceHostMsg_CancelRequest, IPC_MESSAGE_CONTROL1(ResourceHostMsg_CancelRequest,
int /* request_id */) int /* request_id */)
// Follows a redirect that occured for the resource request with the ID given // Follows a redirect that occured for the resource request with the ID given
// as the parameter. // as the parameter.
IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect, IPC_MESSAGE_CONTROL3(ResourceHostMsg_FollowRedirect,
int /* request_id */, int /* request_id */,
bool /* has_new_first_party_for_cookies */, bool /* has_new_first_party_for_cookies */,
GURL /* new_first_party_for_cookies */) GURL /* new_first_party_for_cookies */)
// Makes a synchronous resource request via the browser. // Makes a synchronous resource request via the browser.
IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
...@@ -294,23 +294,23 @@ IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, ...@@ -294,23 +294,23 @@ IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad,
// Sent when the renderer process is done processing a DataReceived // Sent when the renderer process is done processing a DataReceived
// message. // message.
IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataReceived_ACK, IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataReceived_ACK,
int /* request_id */) int /* request_id */)
// Sent when the renderer has processed a DataDownloaded message. // Sent when the renderer has processed a DataDownloaded message.
IPC_MESSAGE_ROUTED1(ResourceHostMsg_DataDownloaded_ACK, IPC_MESSAGE_CONTROL1(ResourceHostMsg_DataDownloaded_ACK,
int /* request_id */) int /* request_id */)
// Sent by the renderer process to acknowledge receipt of a // Sent by the renderer process to acknowledge receipt of a
// UploadProgress message. // UploadProgress message.
IPC_MESSAGE_ROUTED1(ResourceHostMsg_UploadProgress_ACK, IPC_MESSAGE_CONTROL1(ResourceHostMsg_UploadProgress_ACK,
int /* request_id */) int /* request_id */)
// Sent when the renderer process deletes a resource loader. // Sent when the renderer process deletes a resource loader.
IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile, IPC_MESSAGE_CONTROL1(ResourceHostMsg_ReleaseDownloadedFile,
int /* request_id */) int /* request_id */)
// Sent by the renderer when a resource request changes priority. // Sent by the renderer when a resource request changes priority.
IPC_MESSAGE_ROUTED2(ResourceHostMsg_DidChangePriority, IPC_MESSAGE_CONTROL2(ResourceHostMsg_DidChangePriority,
int /* request_id */, int /* request_id */,
net::RequestPriority) net::RequestPriority)
...@@ -163,7 +163,7 @@ void RenderViewFakeResourcesTest::OnRequestResource( ...@@ -163,7 +163,7 @@ void RenderViewFakeResourcesTest::OnRequestResource(
response_head.headers = new net::HttpResponseHeaders(headers); response_head.headers = new net::HttpResponseHeaders(headers);
response_head.mime_type = "text/html"; response_head.mime_type = "text/html";
ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse( ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse(
message.routing_id(), request_id, response_head))); request_id, response_head)));
base::SharedMemory shared_memory; base::SharedMemory shared_memory;
ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(body.size())); ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(body.size()));
...@@ -174,21 +174,18 @@ void RenderViewFakeResourcesTest::OnRequestResource( ...@@ -174,21 +174,18 @@ void RenderViewFakeResourcesTest::OnRequestResource(
&handle)); &handle));
ASSERT_TRUE(channel_->Send(new ResourceMsg_SetDataBuffer( ASSERT_TRUE(channel_->Send(new ResourceMsg_SetDataBuffer(
message.routing_id(),
request_id, request_id,
handle, handle,
body.size(), body.size(),
0))); 0)));
ASSERT_TRUE(channel_->Send(new ResourceMsg_DataReceived( ASSERT_TRUE(channel_->Send(new ResourceMsg_DataReceived(
message.routing_id(),
request_id, request_id,
0, 0,
body.size(), body.size(),
body.size()))); body.size())));
ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete( ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete(
message.routing_id(),
request_id, request_id,
net::OK, net::OK,
false, false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment