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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 child_id, | 683 child_id, |
684 route_id, | 684 route_id, |
685 request_id_, | 685 request_id_, |
686 ResourceType::SUB_RESOURCE, | 686 ResourceType::SUB_RESOURCE, |
687 0, // upload_size | 687 0, // upload_size |
688 download, // is_download | 688 download, // is_download |
689 download, // allow_download | 689 download, // allow_download |
690 false); // has_user_gesture | 690 false); // has_user_gesture |
691 } | 691 } |
692 | 692 |
693 void ResourceDispatcherHost::OnClosePageACK( | 693 void ResourceDispatcherHost::OnSwapOutACK( |
694 const ViewMsg_ClosePage_Params& params) { | 694 const ViewMsg_SwapOut_Params& params) { |
695 if (params.for_cross_site_transition) { | 695 // Closes for cross-site transitions are handled such that the cross-site |
696 // Closes for cross-site transitions are handled such that the cross-site | 696 // transition continues. |
697 // transition continues. | 697 GlobalRequestID global_id(params.new_render_process_host_id, |
698 GlobalRequestID global_id(params.new_render_process_host_id, | 698 params.new_request_id); |
699 params.new_request_id); | 699 PendingRequestList::iterator i = pending_requests_.find(global_id); |
700 PendingRequestList::iterator i = pending_requests_.find(global_id); | 700 if (i != pending_requests_.end()) { |
701 if (i != pending_requests_.end()) { | 701 // The response we were meant to resume could have already been canceled. |
702 // The response we were meant to resume could have already been canceled. | 702 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); |
703 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 703 if (info->cross_site_handler()) |
704 if (info->cross_site_handler()) | 704 info->cross_site_handler()->ResumeResponse(); |
705 info->cross_site_handler()->ResumeResponse(); | |
706 } | |
707 } else { | |
708 // This is a tab close, so we will close the tab in OnClosePageACK. | |
709 DCHECK(params.new_render_process_host_id == -1); | |
710 DCHECK(params.new_request_id == -1); | |
711 } | 705 } |
712 // Update the RenderViewHost's internal state after the ACK. | 706 // Update the RenderViewHost's internal state after the ACK. |
713 CallRenderViewHost(params.closing_process_id, | 707 CallRenderViewHost(params.closing_process_id, |
714 params.closing_route_id, | 708 params.closing_route_id, |
715 &RenderViewHost::OnClosePageACK, | 709 &RenderViewHost::OnSwapOutACK); |
716 params.for_cross_site_transition); | |
717 } | 710 } |
718 | 711 |
719 // We are explicitly forcing the download of 'url'. | 712 // We are explicitly forcing the download of 'url'. |
720 void ResourceDispatcherHost::BeginDownload( | 713 void ResourceDispatcherHost::BeginDownload( |
721 const GURL& url, | 714 const GURL& url, |
722 const GURL& referrer, | 715 const GURL& referrer, |
723 const DownloadSaveInfo& save_info, | 716 const DownloadSaveInfo& save_info, |
724 bool prompt_for_save_location, | 717 bool prompt_for_save_location, |
725 int child_id, | 718 int child_id, |
726 int route_id, | 719 int route_id, |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 return is_prefetch_enabled_; | 1997 return is_prefetch_enabled_; |
2005 } | 1998 } |
2006 | 1999 |
2007 // static | 2000 // static |
2008 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 2001 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
2009 is_prefetch_enabled_ = value; | 2002 is_prefetch_enabled_ = value; |
2010 } | 2003 } |
2011 | 2004 |
2012 // static | 2005 // static |
2013 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 2006 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
OLD | NEW |