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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) | 330 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) |
331 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 331 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
332 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 332 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) |
333 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 333 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
334 OnReleaseDownloadedFile) | 334 OnReleaseDownloadedFile) |
335 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) | 335 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) |
336 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) | 336 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
337 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 337 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
338 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 338 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
339 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) | 339 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) |
340 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 340 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) |
341 IPC_MESSAGE_UNHANDLED(handled = false) | 341 IPC_MESSAGE_UNHANDLED(handled = false) |
342 IPC_END_MESSAGE_MAP_EX() | 342 IPC_END_MESSAGE_MAP_EX() |
343 | 343 |
344 filter_ = NULL; | 344 filter_ = NULL; |
345 return handled; | 345 return handled; |
346 } | 346 } |
347 | 347 |
348 void ResourceDispatcherHost::OnRequestResource( | 348 void ResourceDispatcherHost::OnRequestResource( |
349 const IPC::Message& message, | 349 const IPC::Message& message, |
350 int request_id, | 350 int request_id, |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 child_id, | 668 child_id, |
669 route_id, | 669 route_id, |
670 request_id_, | 670 request_id_, |
671 ResourceType::SUB_RESOURCE, | 671 ResourceType::SUB_RESOURCE, |
672 0, // upload_size | 672 0, // upload_size |
673 download, // is_download | 673 download, // is_download |
674 download, // allow_download | 674 download, // allow_download |
675 false); // has_user_gesture | 675 false); // has_user_gesture |
676 } | 676 } |
677 | 677 |
678 void ResourceDispatcherHost::OnClosePageACK( | 678 void ResourceDispatcherHost::OnSwapOutACK( |
679 const ViewMsg_ClosePage_Params& params) { | 679 const ViewMsg_SwapOut_Params& params) { |
680 if (params.for_cross_site_transition) { | 680 // Closes for cross-site transitions are handled such that the cross-site |
681 // Closes for cross-site transitions are handled such that the cross-site | 681 // transition continues. |
682 // transition continues. | 682 GlobalRequestID global_id(params.new_render_process_host_id, |
683 GlobalRequestID global_id(params.new_render_process_host_id, | 683 params.new_request_id); |
684 params.new_request_id); | 684 PendingRequestList::iterator i = pending_requests_.find(global_id); |
685 PendingRequestList::iterator i = pending_requests_.find(global_id); | 685 if (i != pending_requests_.end()) { |
686 if (i != pending_requests_.end()) { | 686 // The response we were meant to resume could have already been canceled. |
687 // The response we were meant to resume could have already been canceled. | 687 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); |
688 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 688 if (info->cross_site_handler()) |
689 if (info->cross_site_handler()) | 689 info->cross_site_handler()->ResumeResponse(); |
690 info->cross_site_handler()->ResumeResponse(); | |
691 } | |
692 } else { | |
693 // This is a tab close, so we will close the tab in OnClosePageACK. | |
694 DCHECK(params.new_render_process_host_id == -1); | |
695 DCHECK(params.new_request_id == -1); | |
696 } | 690 } |
697 // Update the RenderViewHost's internal state after the ACK. | 691 // Update the RenderViewHost's internal state after the ACK. |
698 CallRenderViewHost(params.closing_process_id, | 692 CallRenderViewHost(params.closing_process_id, |
699 params.closing_route_id, | 693 params.closing_route_id, |
700 &RenderViewHost::OnClosePageACK, | 694 &RenderViewHost::OnSwapOutACK); |
701 params.for_cross_site_transition); | |
702 } | 695 } |
703 | 696 |
704 // We are explicitly forcing the download of 'url'. | 697 // We are explicitly forcing the download of 'url'. |
705 void ResourceDispatcherHost::BeginDownload( | 698 void ResourceDispatcherHost::BeginDownload( |
706 const GURL& url, | 699 const GURL& url, |
707 const GURL& referrer, | 700 const GURL& referrer, |
708 const DownloadSaveInfo& save_info, | 701 const DownloadSaveInfo& save_info, |
709 bool prompt_for_save_location, | 702 bool prompt_for_save_location, |
710 int child_id, | 703 int child_id, |
711 int route_id, | 704 int route_id, |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 return is_prefetch_enabled_; | 1982 return is_prefetch_enabled_; |
1990 } | 1983 } |
1991 | 1984 |
1992 // static | 1985 // static |
1993 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1986 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
1994 is_prefetch_enabled_ = value; | 1987 is_prefetch_enabled_ = value; |
1995 } | 1988 } |
1996 | 1989 |
1997 // static | 1990 // static |
1998 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1991 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
OLD | NEW |