| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 bool handled = true; | 331 bool handled = true; |
| 332 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) | 332 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) |
| 333 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 333 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
| 334 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 334 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) |
| 335 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 335 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
| 336 OnReleaseDownloadedFile) | 336 OnReleaseDownloadedFile) |
| 337 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) | 337 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) |
| 338 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) | 338 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
| 339 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 339 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
| 340 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 340 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
| 341 IPC_MESSAGE_HANDLER(ResourceHostMsg_TransferRequestToNewPage, |
| 342 OnTransferRequestToNewPage) |
| 341 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) | 343 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) |
| 342 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) | 344 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) |
| 343 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, | 345 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 344 OnDidLoadResourceFromMemoryCache) | 346 OnDidLoadResourceFromMemoryCache) |
| 345 IPC_MESSAGE_UNHANDLED(handled = false) | 347 IPC_MESSAGE_UNHANDLED(handled = false) |
| 346 IPC_END_MESSAGE_MAP_EX() | 348 IPC_END_MESSAGE_MAP_EX() |
| 347 | 349 |
| 348 if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { | 350 if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { |
| 349 // We just needed to peek at this message. We still want it to reach its | 351 // We just needed to peek at this message. We still want it to reach its |
| 350 // normal destination. | 352 // normal destination. |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 return; | 629 return; |
| 628 | 630 |
| 629 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 631 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); |
| 630 info->set_waiting_for_upload_progress_ack(false); | 632 info->set_waiting_for_upload_progress_ack(false); |
| 631 } | 633 } |
| 632 | 634 |
| 633 void ResourceDispatcherHost::OnCancelRequest(int request_id) { | 635 void ResourceDispatcherHost::OnCancelRequest(int request_id) { |
| 634 CancelRequest(filter_->child_id(), request_id, true); | 636 CancelRequest(filter_->child_id(), request_id, true); |
| 635 } | 637 } |
| 636 | 638 |
| 639 void ResourceDispatcherHost::OnTransferRequestToNewPage(const IPC::Message& msg, |
| 640 int request_id) { |
| 641 TransferRequestToNewPage(filter_->child_id(), msg.routing_id(), request_id); |
| 642 } |
| 643 |
| 637 void ResourceDispatcherHost::OnFollowRedirect( | 644 void ResourceDispatcherHost::OnFollowRedirect( |
| 638 int request_id, | 645 int request_id, |
| 639 bool has_new_first_party_for_cookies, | 646 bool has_new_first_party_for_cookies, |
| 640 const GURL& new_first_party_for_cookies) { | 647 const GURL& new_first_party_for_cookies) { |
| 641 FollowDeferredRedirect(filter_->child_id(), request_id, | 648 FollowDeferredRedirect(filter_->child_id(), request_id, |
| 642 has_new_first_party_for_cookies, | 649 has_new_first_party_for_cookies, |
| 643 new_first_party_for_cookies); | 650 new_first_party_for_cookies); |
| 644 } | 651 } |
| 645 | 652 |
| 646 ResourceDispatcherHostRequestInfo* | 653 ResourceDispatcherHostRequestInfo* |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 | 1319 |
| 1313 if (CancelRequestInternal(request, from_renderer) && | 1320 if (CancelRequestInternal(request, from_renderer) && |
| 1314 !started_before_cancel) { | 1321 !started_before_cancel) { |
| 1315 // If the request isn't in flight, then we won't get asyncronous | 1322 // If the request isn't in flight, then we won't get asyncronous |
| 1316 // notification, so we have to signal ourselves to finish this | 1323 // notification, so we have to signal ourselves to finish this |
| 1317 // request. | 1324 // request. |
| 1318 OnResponseCompleted(request); | 1325 OnResponseCompleted(request); |
| 1319 } | 1326 } |
| 1320 } | 1327 } |
| 1321 | 1328 |
| 1329 void ResourceDispatcherHost::TransferRequestToNewPage(int process_unique_id, |
| 1330 int new_routing_id, |
| 1331 int request_id) { |
| 1332 PendingRequestList::iterator i = pending_requests_.find( |
| 1333 GlobalRequestID(process_unique_id, request_id)); |
| 1334 if (i == pending_requests_.end()) { |
| 1335 // We probably want to remove this warning eventually, but I wanted to be |
| 1336 // able to notice when this happens during initial development since it |
| 1337 // should be rare and may indicate a bug. |
| 1338 DLOG(WARNING) << "Updating a request that wasn't found"; |
| 1339 return; |
| 1340 } |
| 1341 net::URLRequest* request = i->second; |
| 1342 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1343 info->set_route_id(new_routing_id); |
| 1344 } |
| 1345 |
| 1322 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, | 1346 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, |
| 1323 bool from_renderer) { | 1347 bool from_renderer) { |
| 1324 VLOG(1) << "CancelRequest: " << request->url().spec(); | 1348 VLOG(1) << "CancelRequest: " << request->url().spec(); |
| 1325 | 1349 |
| 1326 // WebKit will send us a cancel for downloads since it no longer handles them. | 1350 // WebKit will send us a cancel for downloads since it no longer handles them. |
| 1327 // In this case, ignore the cancel since we handle downloads in the browser. | 1351 // In this case, ignore the cancel since we handle downloads in the browser. |
| 1328 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1352 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1329 if (!from_renderer || !info->is_download()) { | 1353 if (!from_renderer || !info->is_download()) { |
| 1330 if (info->login_delegate()) { | 1354 if (info->login_delegate()) { |
| 1331 info->login_delegate()->OnRequestCancelled(); | 1355 info->login_delegate()->OnRequestCancelled(); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; | 2130 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; |
| 2107 } | 2131 } |
| 2108 | 2132 |
| 2109 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { | 2133 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { |
| 2110 return allow_cross_origin_auth_prompt_; | 2134 return allow_cross_origin_auth_prompt_; |
| 2111 } | 2135 } |
| 2112 | 2136 |
| 2113 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { | 2137 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { |
| 2114 allow_cross_origin_auth_prompt_ = value; | 2138 allow_cross_origin_auth_prompt_ = value; |
| 2115 } | 2139 } |
| OLD | NEW |