| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) | 308 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) |
| 309 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 309 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
| 310 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 310 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) |
| 311 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 311 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
| 312 OnReleaseDownloadedFile) | 312 OnReleaseDownloadedFile) |
| 313 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) | 313 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) |
| 314 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) | 314 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
| 315 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 315 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
| 316 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 316 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
| 317 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) | 317 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) |
| 318 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 318 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) |
| 319 IPC_MESSAGE_UNHANDLED(handled = false) | 319 IPC_MESSAGE_UNHANDLED(handled = false) |
| 320 IPC_END_MESSAGE_MAP_EX() | 320 IPC_END_MESSAGE_MAP_EX() |
| 321 | 321 |
| 322 filter_ = NULL; | 322 filter_ = NULL; |
| 323 return handled; | 323 return handled; |
| 324 } | 324 } |
| 325 | 325 |
| 326 void ResourceDispatcherHost::OnRequestResource( | 326 void ResourceDispatcherHost::OnRequestResource( |
| 327 const IPC::Message& message, | 327 const IPC::Message& message, |
| 328 int request_id, | 328 int request_id, |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 child_id, | 640 child_id, |
| 641 route_id, | 641 route_id, |
| 642 request_id_, | 642 request_id_, |
| 643 ResourceType::SUB_RESOURCE, | 643 ResourceType::SUB_RESOURCE, |
| 644 0, // upload_size | 644 0, // upload_size |
| 645 download, // is_download | 645 download, // is_download |
| 646 download, // allow_download | 646 download, // allow_download |
| 647 false); // has_user_gesture | 647 false); // has_user_gesture |
| 648 } | 648 } |
| 649 | 649 |
| 650 void ResourceDispatcherHost::OnClosePageACK( | 650 void ResourceDispatcherHost::OnSwapOutACK( |
| 651 const ViewMsg_ClosePage_Params& params) { | 651 const ViewMsg_SwapOut_Params& params) { |
| 652 if (params.for_cross_site_transition) { | 652 // Closes for cross-site transitions are handled such that the cross-site |
| 653 // Closes for cross-site transitions are handled such that the cross-site | 653 // transition continues. |
| 654 // transition continues. | 654 GlobalRequestID global_id(params.new_render_process_host_id, |
| 655 GlobalRequestID global_id(params.new_render_process_host_id, | 655 params.new_request_id); |
| 656 params.new_request_id); | 656 PendingRequestList::iterator i = pending_requests_.find(global_id); |
| 657 PendingRequestList::iterator i = pending_requests_.find(global_id); | 657 if (i != pending_requests_.end()) { |
| 658 if (i != pending_requests_.end()) { | 658 // The response we were meant to resume could have already been canceled. |
| 659 // The response we were meant to resume could have already been canceled. | 659 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); |
| 660 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 660 if (info->cross_site_handler()) |
| 661 if (info->cross_site_handler()) | 661 info->cross_site_handler()->ResumeResponse(); |
| 662 info->cross_site_handler()->ResumeResponse(); | |
| 663 } | |
| 664 } else { | |
| 665 // This is a tab close, so we will close the tab in OnClosePageACK. | |
| 666 DCHECK(params.new_render_process_host_id == -1); | |
| 667 DCHECK(params.new_request_id == -1); | |
| 668 } | 662 } |
| 669 // Update the RenderViewHost's internal state after the ACK. | 663 // Update the RenderViewHost's internal state after the ACK. |
| 670 CallRenderViewHost(params.closing_process_id, | 664 CallRenderViewHost(params.closing_process_id, |
| 671 params.closing_route_id, | 665 params.closing_route_id, |
| 672 &RenderViewHost::OnClosePageACK, | 666 &RenderViewHost::OnSwapOutACK); |
| 673 params.for_cross_site_transition); | |
| 674 } | 667 } |
| 675 | 668 |
| 676 // We are explicitly forcing the download of 'url'. | 669 // We are explicitly forcing the download of 'url'. |
| 677 void ResourceDispatcherHost::BeginDownload( | 670 void ResourceDispatcherHost::BeginDownload( |
| 678 const GURL& url, | 671 const GURL& url, |
| 679 const GURL& referrer, | 672 const GURL& referrer, |
| 680 const DownloadSaveInfo& save_info, | 673 const DownloadSaveInfo& save_info, |
| 681 bool prompt_for_save_location, | 674 bool prompt_for_save_location, |
| 682 int child_id, | 675 int child_id, |
| 683 int route_id, | 676 int route_id, |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 return is_prefetch_enabled_; | 1950 return is_prefetch_enabled_; |
| 1958 } | 1951 } |
| 1959 | 1952 |
| 1960 // static | 1953 // static |
| 1961 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1954 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1962 is_prefetch_enabled_ = value; | 1955 is_prefetch_enabled_ = value; |
| 1963 } | 1956 } |
| 1964 | 1957 |
| 1965 // static | 1958 // static |
| 1966 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1959 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |