OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 20 matching lines...) Expand all Loading... |
31 #include "content/browser/download/save_file_manager.h" | 31 #include "content/browser/download/save_file_manager.h" |
32 #include "content/browser/download/save_file_resource_handler.h" | 32 #include "content/browser/download/save_file_resource_handler.h" |
33 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 33 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
34 #include "content/browser/plugin_service_impl.h" | 34 #include "content/browser/plugin_service_impl.h" |
35 #include "content/browser/renderer_host/async_resource_handler.h" | 35 #include "content/browser/renderer_host/async_resource_handler.h" |
36 #include "content/browser/renderer_host/buffered_resource_handler.h" | 36 #include "content/browser/renderer_host/buffered_resource_handler.h" |
37 #include "content/browser/renderer_host/cross_site_resource_handler.h" | 37 #include "content/browser/renderer_host/cross_site_resource_handler.h" |
38 #include "content/browser/renderer_host/doomed_resource_handler.h" | 38 #include "content/browser/renderer_host/doomed_resource_handler.h" |
39 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" | 39 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" |
40 #include "content/browser/renderer_host/render_view_host_impl.h" | 40 #include "content/browser/renderer_host/render_view_host_impl.h" |
41 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 41 #include "content/browser/renderer_host/resource_request_info_impl.h" |
42 #include "content/browser/renderer_host/resource_message_filter.h" | 42 #include "content/browser/renderer_host/resource_message_filter.h" |
43 #include "content/browser/renderer_host/resource_request_details.h" | 43 #include "content/browser/renderer_host/resource_request_details.h" |
44 #include "content/browser/renderer_host/sync_resource_handler.h" | 44 #include "content/browser/renderer_host/sync_resource_handler.h" |
45 #include "content/browser/renderer_host/throttling_resource_handler.h" | 45 #include "content/browser/renderer_host/throttling_resource_handler.h" |
46 #include "content/browser/ssl/ssl_client_auth_handler.h" | 46 #include "content/browser/ssl/ssl_client_auth_handler.h" |
47 #include "content/browser/ssl/ssl_manager.h" | 47 #include "content/browser/ssl/ssl_manager.h" |
48 #include "content/browser/worker_host/worker_service_impl.h" | 48 #include "content/browser/worker_host/worker_service_impl.h" |
49 #include "content/common/resource_messages.h" | 49 #include "content/common/resource_messages.h" |
50 #include "content/common/ssl_status_serialization.h" | 50 #include "content/common/ssl_status_serialization.h" |
51 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "webkit/blob/blob_storage_controller.h" | 84 #include "webkit/blob/blob_storage_controller.h" |
85 #include "webkit/blob/shareable_file_reference.h" | 85 #include "webkit/blob/shareable_file_reference.h" |
86 | 86 |
87 using base::Time; | 87 using base::Time; |
88 using base::TimeDelta; | 88 using base::TimeDelta; |
89 using base::TimeTicks; | 89 using base::TimeTicks; |
90 using content::BrowserThread; | 90 using content::BrowserThread; |
91 using content::GlobalRequestID; | 91 using content::GlobalRequestID; |
92 using content::RenderViewHostImpl; | 92 using content::RenderViewHostImpl; |
93 using content::ResourceContext; | 93 using content::ResourceContext; |
| 94 using content::ResourceRequestInfo; |
| 95 using content::ResourceRequestInfoImpl; |
94 using content::ResourceResponse; | 96 using content::ResourceResponse; |
95 using content::ResourceThrottle; | 97 using content::ResourceThrottle; |
96 using content::ThrottlingResourceHandler; | 98 using content::ThrottlingResourceHandler; |
97 using content::WebContents; | 99 using content::WebContents; |
98 using content::WorkerServiceImpl; | 100 using content::WorkerServiceImpl; |
99 using webkit_blob::ShareableFileReference; | 101 using webkit_blob::ShareableFileReference; |
100 | 102 |
101 // ---------------------------------------------------------------------------- | 103 // ---------------------------------------------------------------------------- |
102 | 104 |
103 namespace { | 105 namespace { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 delegate_->DownloadStarting(request, context, child_id, route_id, | 376 delegate_->DownloadStarting(request, context, child_id, route_id, |
375 request_id, !request->is_pending(), &throttles); | 377 request_id, !request->is_pending(), &throttles); |
376 if (!throttles.empty()) { | 378 if (!throttles.empty()) { |
377 handler = new ThrottlingResourceHandler(this, handler, child_id, | 379 handler = new ThrottlingResourceHandler(this, handler, child_id, |
378 request_id, throttles.Pass()); | 380 request_id, throttles.Pass()); |
379 } | 381 } |
380 } | 382 } |
381 return handler; | 383 return handler; |
382 } | 384 } |
383 | 385 |
384 void ResourceDispatcherHost::SetRequestInfo( | 386 // static |
385 net::URLRequest* request, | 387 void ResourceDispatcherHost::ClearLoginDelegate(net::URLRequest* request) { |
386 ResourceDispatcherHostRequestInfo* info) { | 388 ResourceRequestInfoImpl* info = |
387 request->SetUserData(NULL, info); | 389 ResourceDispatcherHost::InfoForRequest(request); |
| 390 if (!info) |
| 391 return; |
| 392 |
| 393 info->set_login_delegate(NULL); |
388 } | 394 } |
389 | 395 |
390 void ResourceDispatcherHost::OnShutdown() { | 396 void ResourceDispatcherHost::OnShutdown() { |
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
392 is_shutdown_ = true; | 398 is_shutdown_ = true; |
393 for (PendingRequestList::const_iterator i = pending_requests_.begin(); | 399 for (PendingRequestList::const_iterator i = pending_requests_.begin(); |
394 i != pending_requests_.end(); ++i) { | 400 i != pending_requests_.end(); ++i) { |
395 transferred_navigations_.erase(i->first); | 401 transferred_navigations_.erase(i->first); |
396 } | 402 } |
397 STLDeleteValues(&pending_requests_); | 403 STLDeleteValues(&pending_requests_); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 route_id, | 680 route_id, |
675 is_continuation_of_transferred_request, | 681 is_continuation_of_transferred_request, |
676 &throttles); | 682 &throttles); |
677 if (!throttles.empty()) { | 683 if (!throttles.empty()) { |
678 handler = new ThrottlingResourceHandler(this, handler, child_id, | 684 handler = new ThrottlingResourceHandler(this, handler, child_id, |
679 request_id, throttles.Pass()); | 685 request_id, throttles.Pass()); |
680 } | 686 } |
681 } | 687 } |
682 | 688 |
683 // Make extra info and read footer (contains request ID). | 689 // Make extra info and read footer (contains request ID). |
684 ResourceDispatcherHostRequestInfo* extra_info = | 690 ResourceRequestInfoImpl* extra_info = |
685 new ResourceDispatcherHostRequestInfo( | 691 new ResourceRequestInfoImpl( |
686 handler, | 692 handler, |
687 process_type, | 693 process_type, |
688 child_id, | 694 child_id, |
689 route_id, | 695 route_id, |
690 request_data.origin_pid, | 696 request_data.origin_pid, |
691 request_id, | 697 request_id, |
692 request_data.is_main_frame, | 698 request_data.is_main_frame, |
693 request_data.frame_id, | 699 request_data.frame_id, |
694 request_data.parent_is_main_frame, | 700 request_data.parent_is_main_frame, |
695 request_data.parent_frame_id, | 701 request_data.parent_frame_id, |
696 request_data.resource_type, | 702 request_data.resource_type, |
697 request_data.transition_type, | 703 request_data.transition_type, |
698 upload_size, | 704 upload_size, |
699 false, // is download | 705 false, // is download |
700 ResourceType::IsFrame(request_data.resource_type), // allow_download | 706 ResourceType::IsFrame(request_data.resource_type), // allow_download |
701 request_data.has_user_gesture, | 707 request_data.has_user_gesture, |
702 request_data.referrer_policy, | 708 request_data.referrer_policy, |
703 resource_context); | 709 resource_context); |
704 SetRequestInfo(request, extra_info); // Request takes ownership. | 710 extra_info->AssociateWithRequest(request); // Request takes ownership. |
705 | 711 |
706 if (request->url().SchemeIs(chrome::kBlobScheme)) { | 712 if (request->url().SchemeIs(chrome::kBlobScheme)) { |
707 // Hang on to a reference to ensure the blob is not released prior | 713 // Hang on to a reference to ensure the blob is not released prior |
708 // to the job being started. | 714 // to the job being started. |
709 webkit_blob::BlobStorageController* controller = | 715 webkit_blob::BlobStorageController* controller = |
710 ResourceContext::GetBlobStorageController(resource_context); | 716 ResourceContext::GetBlobStorageController(resource_context); |
711 extra_info->set_requested_blob_data( | 717 extra_info->set_requested_blob_data( |
712 controller->GetBlobDataFromUrl(request->url())); | 718 controller->GetBlobDataFromUrl(request->url())); |
713 } | 719 } |
714 | 720 |
715 // Have the appcache associate its extra info with the request. | 721 // Have the appcache associate its extra info with the request. |
716 appcache::AppCacheInterceptor::SetExtraRequestInfo( | 722 appcache::AppCacheInterceptor::SetExtraRequestInfo( |
717 request, ResourceContext::GetAppCacheService(resource_context), child_id, | 723 request, ResourceContext::GetAppCacheService(resource_context), child_id, |
718 request_data.appcache_host_id, request_data.resource_type); | 724 request_data.appcache_host_id, request_data.resource_type); |
719 | 725 |
720 if (deferred_request) { | 726 if (deferred_request) { |
721 // This is a request that has been transferred from another process, so | 727 // This is a request that has been transferred from another process, so |
722 // resume it rather than continuing the regular procedure for starting a | 728 // resume it rather than continuing the regular procedure for starting a |
723 // request. Currently this is only done for redirects. | 729 // request. Currently this is only done for redirects. |
724 GlobalRequestID global_id(extra_info->child_id(), extra_info->request_id()); | 730 GlobalRequestID global_id(extra_info->GetChildID(), |
| 731 extra_info->GetRequestID()); |
725 pending_requests_[global_id] = request; | 732 pending_requests_[global_id] = request; |
726 request->FollowDeferredRedirect(); | 733 request->FollowDeferredRedirect(); |
727 } else { | 734 } else { |
728 BeginRequestInternal(request); | 735 BeginRequestInternal(request); |
729 } | 736 } |
730 } | 737 } |
731 | 738 |
732 void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) { | 739 void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) { |
733 DCHECK(pending_requests_.end() == | 740 DCHECK(pending_requests_.end() == |
734 pending_requests_.find( | 741 pending_requests_.find( |
735 GlobalRequestID(filter_->child_id(), request_id))); | 742 GlobalRequestID(filter_->child_id(), request_id))); |
736 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 743 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
737 } | 744 } |
738 | 745 |
739 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { | 746 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { |
740 DataReceivedACK(filter_->child_id(), request_id); | 747 DataReceivedACK(filter_->child_id(), request_id); |
741 } | 748 } |
742 | 749 |
743 void ResourceDispatcherHost::DataReceivedACK(int child_id, | 750 void ResourceDispatcherHost::DataReceivedACK(int child_id, |
744 int request_id) { | 751 int request_id) { |
745 PendingRequestList::iterator i = pending_requests_.find( | 752 PendingRequestList::iterator i = pending_requests_.find( |
746 GlobalRequestID(child_id, request_id)); | 753 GlobalRequestID(child_id, request_id)); |
747 if (i == pending_requests_.end()) | 754 if (i == pending_requests_.end()) |
748 return; | 755 return; |
749 | 756 |
750 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 757 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
751 | 758 |
752 // Decrement the number of pending data messages. | 759 // Decrement the number of pending data messages. |
753 info->DecrementPendingDataCount(); | 760 info->DecrementPendingDataCount(); |
754 | 761 |
755 // If the pending data count was higher than the max, resume the request. | 762 // If the pending data count was higher than the max, resume the request. |
756 if (info->pending_data_count() == kMaxPendingDataMessages) { | 763 if (info->pending_data_count() == kMaxPendingDataMessages) { |
757 // Decrement the pending data count one more time because we also | 764 // Decrement the pending data count one more time because we also |
758 // incremented it before pausing the request. | 765 // incremented it before pausing the request. |
759 info->DecrementPendingDataCount(); | 766 info->DecrementPendingDataCount(); |
760 | 767 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 return false; | 811 return false; |
805 } | 812 } |
806 | 813 |
807 void ResourceDispatcherHost::OnUploadProgressACK(int request_id) { | 814 void ResourceDispatcherHost::OnUploadProgressACK(int request_id) { |
808 int child_id = filter_->child_id(); | 815 int child_id = filter_->child_id(); |
809 PendingRequestList::iterator i = pending_requests_.find( | 816 PendingRequestList::iterator i = pending_requests_.find( |
810 GlobalRequestID(child_id, request_id)); | 817 GlobalRequestID(child_id, request_id)); |
811 if (i == pending_requests_.end()) | 818 if (i == pending_requests_.end()) |
812 return; | 819 return; |
813 | 820 |
814 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 821 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
815 info->set_waiting_for_upload_progress_ack(false); | 822 info->set_waiting_for_upload_progress_ack(false); |
816 } | 823 } |
817 | 824 |
818 void ResourceDispatcherHost::OnCancelRequest(int request_id) { | 825 void ResourceDispatcherHost::OnCancelRequest(int request_id) { |
819 CancelRequest(filter_->child_id(), request_id, true); | 826 CancelRequest(filter_->child_id(), request_id, true); |
820 } | 827 } |
821 | 828 |
822 // Assigns the pending request a new routing_id because it was transferred | 829 // Assigns the pending request a new routing_id because it was transferred |
823 // to a new page. | 830 // to a new page. |
824 void ResourceDispatcherHost::OnTransferRequestToNewPage(int new_routing_id, | 831 void ResourceDispatcherHost::OnTransferRequestToNewPage(int new_routing_id, |
825 int request_id) { | 832 int request_id) { |
826 PendingRequestList::iterator i = pending_requests_.find( | 833 PendingRequestList::iterator i = pending_requests_.find( |
827 GlobalRequestID(filter_->child_id(), request_id)); | 834 GlobalRequestID(filter_->child_id(), request_id)); |
828 if (i == pending_requests_.end()) { | 835 if (i == pending_requests_.end()) { |
829 // We probably want to remove this warning eventually, but I wanted to be | 836 // We probably want to remove this warning eventually, but I wanted to be |
830 // able to notice when this happens during initial development since it | 837 // able to notice when this happens during initial development since it |
831 // should be rare and may indicate a bug. | 838 // should be rare and may indicate a bug. |
832 DVLOG(1) << "Updating a request that wasn't found"; | 839 DVLOG(1) << "Updating a request that wasn't found"; |
833 return; | 840 return; |
834 } | 841 } |
835 net::URLRequest* request = i->second; | 842 net::URLRequest* request = i->second; |
836 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 843 ResourceRequestInfoImpl* info = InfoForRequest(request); |
837 info->set_route_id(new_routing_id); | 844 info->set_route_id(new_routing_id); |
838 } | 845 } |
839 | 846 |
840 void ResourceDispatcherHost::OnFollowRedirect( | 847 void ResourceDispatcherHost::OnFollowRedirect( |
841 int request_id, | 848 int request_id, |
842 bool has_new_first_party_for_cookies, | 849 bool has_new_first_party_for_cookies, |
843 const GURL& new_first_party_for_cookies) { | 850 const GURL& new_first_party_for_cookies) { |
844 FollowDeferredRedirect(filter_->child_id(), request_id, | 851 FollowDeferredRedirect(filter_->child_id(), request_id, |
845 has_new_first_party_for_cookies, | 852 has_new_first_party_for_cookies, |
846 new_first_party_for_cookies); | 853 new_first_party_for_cookies); |
847 } | 854 } |
848 | 855 |
849 ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::CreateRequestInfo( | 856 ResourceRequestInfoImpl* ResourceDispatcherHost::CreateRequestInfo( |
850 ResourceHandler* handler, | 857 ResourceHandler* handler, |
851 int child_id, | 858 int child_id, |
852 int route_id, | 859 int route_id, |
853 bool download, | 860 bool download, |
854 content::ResourceContext* context) { | 861 content::ResourceContext* context) { |
855 return new ResourceDispatcherHostRequestInfo( | 862 return new ResourceRequestInfoImpl( |
856 handler, | 863 handler, |
857 content::PROCESS_TYPE_RENDERER, | 864 content::PROCESS_TYPE_RENDERER, |
858 child_id, | 865 child_id, |
859 route_id, | 866 route_id, |
860 0, | 867 0, |
861 request_id_, | 868 request_id_, |
862 false, // is_main_frame | 869 false, // is_main_frame |
863 -1, // frame_id | 870 -1, // frame_id |
864 false, // parent_is_main_frame | 871 false, // parent_is_main_frame |
865 -1, // parent_frame_id | 872 -1, // parent_frame_id |
866 ResourceType::SUB_RESOURCE, | 873 ResourceType::SUB_RESOURCE, |
867 content::PAGE_TRANSITION_LINK, | 874 content::PAGE_TRANSITION_LINK, |
868 0, // upload_size | 875 0, // upload_size |
869 download, // is_download | 876 download, // is_download |
870 download, // allow_download | 877 download, // allow_download |
871 false, // has_user_gesture | 878 false, // has_user_gesture |
872 WebKit::WebReferrerPolicyDefault, | 879 WebKit::WebReferrerPolicyDefault, |
873 context); | 880 context); |
874 } | 881 } |
875 | 882 |
876 void ResourceDispatcherHost::OnSwapOutACK( | 883 void ResourceDispatcherHost::OnSwapOutACK( |
877 const ViewMsg_SwapOut_Params& params) { | 884 const ViewMsg_SwapOut_Params& params) { |
878 // Closes for cross-site transitions are handled such that the cross-site | 885 // Closes for cross-site transitions are handled such that the cross-site |
879 // transition continues. | 886 // transition continues. |
880 GlobalRequestID global_id(params.new_render_process_host_id, | 887 GlobalRequestID global_id(params.new_render_process_host_id, |
881 params.new_request_id); | 888 params.new_request_id); |
882 PendingRequestList::iterator i = pending_requests_.find(global_id); | 889 PendingRequestList::iterator i = pending_requests_.find(global_id); |
883 if (i != pending_requests_.end()) { | 890 if (i != pending_requests_.end()) { |
884 // The response we were meant to resume could have already been canceled. | 891 // The response we were meant to resume could have already been canceled. |
885 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 892 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
886 if (info->cross_site_handler()) | 893 if (info->cross_site_handler()) |
887 info->cross_site_handler()->ResumeResponse(); | 894 info->cross_site_handler()->ResumeResponse(); |
888 } | 895 } |
889 // Update the RenderViewHost's internal state after the ACK. | 896 // Update the RenderViewHost's internal state after the ACK. |
890 content::BrowserThread::PostTask( | 897 content::BrowserThread::PostTask( |
891 content::BrowserThread::UI, | 898 content::BrowserThread::UI, |
892 FROM_HERE, | 899 FROM_HERE, |
893 base::Bind(&OnSwapOutACKHelper, | 900 base::Bind(&OnSwapOutACKHelper, |
894 params.closing_process_id, | 901 params.closing_process_id, |
895 params.closing_route_id)); | 902 params.closing_route_id)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 CreateResourceHandlerForDownload(request.get(), context, child_id, | 962 CreateResourceHandlerForDownload(request.get(), context, child_id, |
956 route_id, request_id_, save_info, | 963 route_id, request_id_, save_info, |
957 started_cb)); | 964 started_cb)); |
958 | 965 |
959 if (!request_context->job_factory()->IsHandledURL(url)) { | 966 if (!request_context->job_factory()->IsHandledURL(url)) { |
960 VLOG(1) << "Download request for unsupported protocol: " | 967 VLOG(1) << "Download request for unsupported protocol: " |
961 << url.possibly_invalid_spec(); | 968 << url.possibly_invalid_spec(); |
962 return net::ERR_ACCESS_DENIED; | 969 return net::ERR_ACCESS_DENIED; |
963 } | 970 } |
964 | 971 |
965 ResourceDispatcherHostRequestInfo* extra_info = | 972 ResourceRequestInfoImpl* extra_info = |
966 CreateRequestInfo(handler, child_id, route_id, true, context); | 973 CreateRequestInfo(handler, child_id, route_id, true, context); |
967 SetRequestInfo(request.get(), extra_info); // Request takes ownership. | 974 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
968 | 975 |
969 BeginRequestInternal(request.release()); | 976 BeginRequestInternal(request.release()); |
970 | 977 |
971 return net::OK; | 978 return net::OK; |
972 } | 979 } |
973 | 980 |
974 // This function is only used for saving feature. | 981 // This function is only used for saving feature. |
975 void ResourceDispatcherHost::BeginSaveFile( | 982 void ResourceDispatcherHost::BeginSaveFile( |
976 const GURL& url, | 983 const GURL& url, |
977 const GURL& referrer, | 984 const GURL& referrer, |
(...skipping 23 matching lines...) Expand all Loading... |
1001 | 1008 |
1002 net::URLRequest* request = new net::URLRequest(url, this); | 1009 net::URLRequest* request = new net::URLRequest(url, this); |
1003 request->set_method("GET"); | 1010 request->set_method("GET"); |
1004 request->set_referrer(MaybeStripReferrer(referrer).spec()); | 1011 request->set_referrer(MaybeStripReferrer(referrer).spec()); |
1005 // So far, for saving page, we need fetch content from cache, in the | 1012 // So far, for saving page, we need fetch content from cache, in the |
1006 // future, maybe we can use a configuration to configure this behavior. | 1013 // future, maybe we can use a configuration to configure this behavior. |
1007 request->set_load_flags(net::LOAD_PREFERRING_CACHE); | 1014 request->set_load_flags(net::LOAD_PREFERRING_CACHE); |
1008 request->set_context(context->GetRequestContext()); | 1015 request->set_context(context->GetRequestContext()); |
1009 | 1016 |
1010 // Since we're just saving some resources we need, disallow downloading. | 1017 // Since we're just saving some resources we need, disallow downloading. |
1011 ResourceDispatcherHostRequestInfo* extra_info = | 1018 ResourceRequestInfoImpl* extra_info = |
1012 CreateRequestInfo(handler, child_id, route_id, false, context); | 1019 CreateRequestInfo(handler, child_id, route_id, false, context); |
1013 SetRequestInfo(request, extra_info); // Request takes ownership. | 1020 extra_info->AssociateWithRequest(request); // Request takes ownership. |
1014 | 1021 |
1015 BeginRequestInternal(request); | 1022 BeginRequestInternal(request); |
1016 } | 1023 } |
1017 | 1024 |
1018 void ResourceDispatcherHost::FollowDeferredRedirect( | 1025 void ResourceDispatcherHost::FollowDeferredRedirect( |
1019 int child_id, | 1026 int child_id, |
1020 int request_id, | 1027 int request_id, |
1021 bool has_new_first_party_for_cookies, | 1028 bool has_new_first_party_for_cookies, |
1022 const GURL& new_first_party_for_cookies) { | 1029 const GURL& new_first_party_for_cookies) { |
1023 PendingRequestList::iterator i = pending_requests_.find( | 1030 PendingRequestList::iterator i = pending_requests_.find( |
(...skipping 27 matching lines...) Expand all Loading... |
1051 | 1058 |
1052 bool ResourceDispatcherHost::WillSendData(int child_id, | 1059 bool ResourceDispatcherHost::WillSendData(int child_id, |
1053 int request_id) { | 1060 int request_id) { |
1054 PendingRequestList::iterator i = pending_requests_.find( | 1061 PendingRequestList::iterator i = pending_requests_.find( |
1055 GlobalRequestID(child_id, request_id)); | 1062 GlobalRequestID(child_id, request_id)); |
1056 if (i == pending_requests_.end()) { | 1063 if (i == pending_requests_.end()) { |
1057 NOTREACHED() << "WillSendData for invalid request"; | 1064 NOTREACHED() << "WillSendData for invalid request"; |
1058 return false; | 1065 return false; |
1059 } | 1066 } |
1060 | 1067 |
1061 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 1068 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
1062 | 1069 |
1063 info->IncrementPendingDataCount(); | 1070 info->IncrementPendingDataCount(); |
1064 if (info->pending_data_count() > kMaxPendingDataMessages) { | 1071 if (info->pending_data_count() > kMaxPendingDataMessages) { |
1065 // We reached the max number of data messages that can be sent to | 1072 // We reached the max number of data messages that can be sent to |
1066 // the renderer for a given request. Pause the request and wait for | 1073 // the renderer for a given request. Pause the request and wait for |
1067 // the renderer to start processing them before resuming it. | 1074 // the renderer to start processing them before resuming it. |
1068 PauseRequest(child_id, request_id, true); | 1075 PauseRequest(child_id, request_id, true); |
1069 return false; | 1076 return false; |
1070 } | 1077 } |
1071 | 1078 |
1072 return true; | 1079 return true; |
1073 } | 1080 } |
1074 | 1081 |
1075 void ResourceDispatcherHost::PauseRequest(int child_id, | 1082 void ResourceDispatcherHost::PauseRequest(int child_id, |
1076 int request_id, | 1083 int request_id, |
1077 bool pause) { | 1084 bool pause) { |
1078 GlobalRequestID global_id(child_id, request_id); | 1085 GlobalRequestID global_id(child_id, request_id); |
1079 PendingRequestList::iterator i = pending_requests_.find(global_id); | 1086 PendingRequestList::iterator i = pending_requests_.find(global_id); |
1080 if (i == pending_requests_.end()) { | 1087 if (i == pending_requests_.end()) { |
1081 DVLOG(1) << "Pausing a request that wasn't found"; | 1088 DVLOG(1) << "Pausing a request that wasn't found"; |
1082 return; | 1089 return; |
1083 } | 1090 } |
1084 | 1091 |
1085 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 1092 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
1086 int pause_count = info->pause_count() + (pause ? 1 : -1); | 1093 int pause_count = info->pause_count() + (pause ? 1 : -1); |
1087 if (pause_count < 0) { | 1094 if (pause_count < 0) { |
1088 NOTREACHED(); // Unbalanced call to pause. | 1095 NOTREACHED(); // Unbalanced call to pause. |
1089 return; | 1096 return; |
1090 } | 1097 } |
1091 info->set_pause_count(pause_count); | 1098 info->set_pause_count(pause_count); |
1092 | 1099 |
1093 VLOG(1) << "To pause (" << pause << "): " << i->second->url().spec(); | 1100 VLOG(1) << "To pause (" << pause << "): " << i->second->url().spec(); |
1094 | 1101 |
1095 // If we're resuming, kick the request to start reading again. Run the read | 1102 // If we're resuming, kick the request to start reading again. Run the read |
(...skipping 27 matching lines...) Expand all Loading... |
1123 // Since pending_requests_ is a map, we first build up a list of all of the | 1130 // Since pending_requests_ is a map, we first build up a list of all of the |
1124 // matching requests to be cancelled, and then we cancel them. Since there | 1131 // matching requests to be cancelled, and then we cancel them. Since there |
1125 // may be more than one request to cancel, we cannot simply hold onto the map | 1132 // may be more than one request to cancel, we cannot simply hold onto the map |
1126 // iterators found in the first loop. | 1133 // iterators found in the first loop. |
1127 | 1134 |
1128 // Find the global ID of all matching elements. | 1135 // Find the global ID of all matching elements. |
1129 std::vector<GlobalRequestID> matching_requests; | 1136 std::vector<GlobalRequestID> matching_requests; |
1130 for (PendingRequestList::const_iterator i = pending_requests_.begin(); | 1137 for (PendingRequestList::const_iterator i = pending_requests_.begin(); |
1131 i != pending_requests_.end(); ++i) { | 1138 i != pending_requests_.end(); ++i) { |
1132 if (i->first.child_id == child_id) { | 1139 if (i->first.child_id == child_id) { |
1133 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 1140 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
1134 GlobalRequestID id(child_id, i->first.request_id); | 1141 GlobalRequestID id(child_id, i->first.request_id); |
1135 DCHECK(id == i->first); | 1142 DCHECK(id == i->first); |
1136 // Don't cancel navigations that are transferring to another process, | 1143 // Don't cancel navigations that are transferring to another process, |
1137 // since they belong to another process now. | 1144 // since they belong to another process now. |
1138 if (!info->is_download() && | 1145 if (!info->is_download() && |
1139 (transferred_navigations_.find(id) == | 1146 (transferred_navigations_.find(id) == |
1140 transferred_navigations_.end()) && | 1147 transferred_navigations_.end()) && |
1141 (route_id == -1 || route_id == info->route_id())) { | 1148 (route_id == -1 || route_id == info->GetRouteID())) { |
1142 matching_requests.push_back( | 1149 matching_requests.push_back( |
1143 GlobalRequestID(child_id, i->first.request_id)); | 1150 GlobalRequestID(child_id, i->first.request_id)); |
1144 } | 1151 } |
1145 } | 1152 } |
1146 } | 1153 } |
1147 | 1154 |
1148 // Remove matches. | 1155 // Remove matches. |
1149 for (size_t i = 0; i < matching_requests.size(); ++i) { | 1156 for (size_t i = 0; i < matching_requests.size(); ++i) { |
1150 PendingRequestList::iterator iter = | 1157 PendingRequestList::iterator iter = |
1151 pending_requests_.find(matching_requests[i]); | 1158 pending_requests_.find(matching_requests[i]); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1192 DCHECK(context); | 1199 DCHECK(context); |
1193 | 1200 |
1194 // Note that request cancellation has side effects. Therefore, we gather all | 1201 // Note that request cancellation has side effects. Therefore, we gather all |
1195 // the requests to cancel first, and then we start cancelling. We assert at | 1202 // the requests to cancel first, and then we start cancelling. We assert at |
1196 // the end that there are no more to cancel since the context is about to go | 1203 // the end that there are no more to cancel since the context is about to go |
1197 // away. | 1204 // away. |
1198 std::vector<net::URLRequest*> requests_to_cancel; | 1205 std::vector<net::URLRequest*> requests_to_cancel; |
1199 for (PendingRequestList::iterator i = pending_requests_.begin(); | 1206 for (PendingRequestList::iterator i = pending_requests_.begin(); |
1200 i != pending_requests_.end();) { | 1207 i != pending_requests_.end();) { |
1201 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 1208 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
1202 if (info->context() == context) { | 1209 if (info->GetContext() == context) { |
1203 requests_to_cancel.push_back(i->second); | 1210 requests_to_cancel.push_back(i->second); |
1204 pending_requests_.erase(i++); | 1211 pending_requests_.erase(i++); |
1205 } else { | 1212 } else { |
1206 ++i; | 1213 ++i; |
1207 } | 1214 } |
1208 } | 1215 } |
1209 | 1216 |
1210 for (BlockedRequestMap::iterator i = blocked_requests_map_.begin(); | 1217 for (BlockedRequestMap::iterator i = blocked_requests_map_.begin(); |
1211 i != blocked_requests_map_.end();) { | 1218 i != blocked_requests_map_.end();) { |
1212 BlockedRequestsList* requests = i->second; | 1219 BlockedRequestsList* requests = i->second; |
1213 if (requests->empty()) { | 1220 if (requests->empty()) { |
1214 // This can happen if BlockRequestsForRoute() has been called for a route, | 1221 // This can happen if BlockRequestsForRoute() has been called for a route, |
1215 // but we haven't blocked any matching requests yet. | 1222 // but we haven't blocked any matching requests yet. |
1216 ++i; | 1223 ++i; |
1217 continue; | 1224 continue; |
1218 } | 1225 } |
1219 ResourceDispatcherHostRequestInfo* info = | 1226 ResourceRequestInfoImpl* info = |
1220 InfoForRequest(requests->front()); | 1227 InfoForRequest(requests->front()); |
1221 if (info->context() == context) { | 1228 if (info->GetContext() == context) { |
1222 blocked_requests_map_.erase(i++); | 1229 blocked_requests_map_.erase(i++); |
1223 for (BlockedRequestsList::const_iterator it = requests->begin(); | 1230 for (BlockedRequestsList::const_iterator it = requests->begin(); |
1224 it != requests->end(); ++it) { | 1231 it != requests->end(); ++it) { |
1225 net::URLRequest* request = *it; | 1232 net::URLRequest* request = *it; |
1226 info = InfoForRequest(request); | 1233 info = InfoForRequest(request); |
1227 // We make the assumption that all requests on the list have the same | 1234 // We make the assumption that all requests on the list have the same |
1228 // ResourceContext. | 1235 // ResourceContext. |
1229 DCHECK_EQ(context, info->context()); | 1236 DCHECK_EQ(context, info->GetContext()); |
1230 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), | 1237 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
1231 info->child_id()); | 1238 info->GetChildID()); |
1232 requests_to_cancel.push_back(request); | 1239 requests_to_cancel.push_back(request); |
1233 } | 1240 } |
1234 delete requests; | 1241 delete requests; |
1235 } else { | 1242 } else { |
1236 ++i; | 1243 ++i; |
1237 } | 1244 } |
1238 } | 1245 } |
1239 | 1246 |
1240 for (std::vector<net::URLRequest*>::iterator i = requests_to_cancel.begin(); | 1247 for (std::vector<net::URLRequest*>::iterator i = requests_to_cancel.begin(); |
1241 i != requests_to_cancel.end(); ++i) { | 1248 i != requests_to_cancel.end(); ++i) { |
1242 net::URLRequest* request = *i; | 1249 net::URLRequest* request = *i; |
1243 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1250 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1244 // There is no strict requirement that this be the case, but currently | 1251 // There is no strict requirement that this be the case, but currently |
1245 // downloads and transferred requests are the only requests that aren't | 1252 // downloads and transferred requests are the only requests that aren't |
1246 // cancelled when the associated processes go away. It may be OK for this | 1253 // cancelled when the associated processes go away. It may be OK for this |
1247 // invariant to change in the future, but if this assertion fires without | 1254 // invariant to change in the future, but if this assertion fires without |
1248 // the invariant changing, then it's indicative of a leak. | 1255 // the invariant changing, then it's indicative of a leak. |
1249 GlobalRequestID request_id(info->child_id(), info->request_id()); | 1256 GlobalRequestID request_id(info->GetChildID(), info->GetRequestID()); |
1250 bool is_transferred = IsTransferredNavigation(request_id); | 1257 bool is_transferred = IsTransferredNavigation(request_id); |
1251 DCHECK(info->is_download() || is_transferred); | 1258 DCHECK(info->is_download() || is_transferred); |
1252 if (is_transferred) | 1259 if (is_transferred) |
1253 transferred_navigations_.erase(request_id); | 1260 transferred_navigations_.erase(request_id); |
1254 delete request; | 1261 delete request; |
1255 } | 1262 } |
1256 | 1263 |
1257 // Validate that no more requests for this context were added. | 1264 // Validate that no more requests for this context were added. |
1258 for (PendingRequestList::const_iterator i = pending_requests_.begin(); | 1265 for (PendingRequestList::const_iterator i = pending_requests_.begin(); |
1259 i != pending_requests_.end(); ++i) { | 1266 i != pending_requests_.end(); ++i) { |
1260 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); | 1267 ResourceRequestInfoImpl* info = InfoForRequest(i->second); |
1261 DCHECK_NE(info->context(), context); | 1268 DCHECK_NE(info->GetContext(), context); |
1262 } | 1269 } |
1263 | 1270 |
1264 for (BlockedRequestMap::const_iterator i = blocked_requests_map_.begin(); | 1271 for (BlockedRequestMap::const_iterator i = blocked_requests_map_.begin(); |
1265 i != blocked_requests_map_.end(); ++i) { | 1272 i != blocked_requests_map_.end(); ++i) { |
1266 BlockedRequestsList* requests = i->second; | 1273 BlockedRequestsList* requests = i->second; |
1267 if (!requests->empty()) { | 1274 if (!requests->empty()) { |
1268 ResourceDispatcherHostRequestInfo* info = | 1275 ResourceRequestInfoImpl* info = |
1269 InfoForRequest(requests->front()); | 1276 InfoForRequest(requests->front()); |
1270 DCHECK_NE(info->context(), context); | 1277 DCHECK_NE(info->GetContext(), context); |
1271 } | 1278 } |
1272 } | 1279 } |
1273 } | 1280 } |
1274 | 1281 |
1275 // Cancels the request and removes it from the list. | 1282 // Cancels the request and removes it from the list. |
1276 void ResourceDispatcherHost::RemovePendingRequest(int child_id, | 1283 void ResourceDispatcherHost::RemovePendingRequest(int child_id, |
1277 int request_id) { | 1284 int request_id) { |
1278 PendingRequestList::iterator i = pending_requests_.find( | 1285 PendingRequestList::iterator i = pending_requests_.find( |
1279 GlobalRequestID(child_id, request_id)); | 1286 GlobalRequestID(child_id, request_id)); |
1280 if (i == pending_requests_.end()) { | 1287 if (i == pending_requests_.end()) { |
1281 NOTREACHED() << "Trying to remove a request that's not here"; | 1288 NOTREACHED() << "Trying to remove a request that's not here"; |
1282 return; | 1289 return; |
1283 } | 1290 } |
1284 RemovePendingRequest(i); | 1291 RemovePendingRequest(i); |
1285 } | 1292 } |
1286 | 1293 |
1287 void ResourceDispatcherHost::RemovePendingRequest( | 1294 void ResourceDispatcherHost::RemovePendingRequest( |
1288 const PendingRequestList::iterator& iter) { | 1295 const PendingRequestList::iterator& iter) { |
1289 ResourceDispatcherHostRequestInfo* info = InfoForRequest(iter->second); | 1296 ResourceRequestInfoImpl* info = InfoForRequest(iter->second); |
1290 | 1297 |
1291 // Remove the memory credit that we added when pushing the request onto | 1298 // Remove the memory credit that we added when pushing the request onto |
1292 // the pending list. | 1299 // the pending list. |
1293 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), | 1300 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
1294 info->child_id()); | 1301 info->GetChildID()); |
1295 | 1302 |
1296 // Notify interested parties that the request object is going away. | 1303 // Notify interested parties that the request object is going away. |
1297 if (info->login_delegate()) | 1304 if (info->login_delegate()) |
1298 info->login_delegate()->OnRequestCancelled(); | 1305 info->login_delegate()->OnRequestCancelled(); |
1299 if (info->ssl_client_auth_handler()) | 1306 if (info->ssl_client_auth_handler()) |
1300 info->ssl_client_auth_handler()->OnRequestCancelled(); | 1307 info->ssl_client_auth_handler()->OnRequestCancelled(); |
1301 transferred_navigations_.erase( | 1308 transferred_navigations_.erase( |
1302 GlobalRequestID(info->child_id(), info->request_id())); | 1309 GlobalRequestID(info->GetChildID(), info->GetRequestID())); |
1303 | 1310 |
1304 delete iter->second; | 1311 delete iter->second; |
1305 pending_requests_.erase(iter); | 1312 pending_requests_.erase(iter); |
1306 | 1313 |
1307 // If we have no more pending requests, then stop the load state monitor | 1314 // If we have no more pending requests, then stop the load state monitor |
1308 if (pending_requests_.empty()) | 1315 if (pending_requests_.empty()) |
1309 update_load_states_timer_.Stop(); | 1316 update_load_states_timer_.Stop(); |
1310 } | 1317 } |
1311 | 1318 |
1312 // net::URLRequest::Delegate --------------------------------------------------- | 1319 // net::URLRequest::Delegate --------------------------------------------------- |
1313 | 1320 |
1314 void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request, | 1321 void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request, |
1315 const GURL& new_url, | 1322 const GURL& new_url, |
1316 bool* defer_redirect) { | 1323 bool* defer_redirect) { |
1317 VLOG(1) << "OnReceivedRedirect: " << request->url().spec(); | 1324 VLOG(1) << "OnReceivedRedirect: " << request->url().spec(); |
1318 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1325 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1319 | 1326 |
1320 DCHECK(request->status().is_success()); | 1327 DCHECK(request->status().is_success()); |
1321 | 1328 |
1322 if (info->process_type() != content::PROCESS_TYPE_PLUGIN && | 1329 if (info->process_type() != content::PROCESS_TYPE_PLUGIN && |
1323 !ChildProcessSecurityPolicyImpl::GetInstance()-> | 1330 !ChildProcessSecurityPolicyImpl::GetInstance()-> |
1324 CanRequestURL(info->child_id(), new_url)) { | 1331 CanRequestURL(info->GetChildID(), new_url)) { |
1325 VLOG(1) << "Denied unauthorized request for " | 1332 VLOG(1) << "Denied unauthorized request for " |
1326 << new_url.possibly_invalid_spec(); | 1333 << new_url.possibly_invalid_spec(); |
1327 | 1334 |
1328 // Tell the renderer that this request was disallowed. | 1335 // Tell the renderer that this request was disallowed. |
1329 CancelRequestInternal(request, false); | 1336 CancelRequestInternal(request, false); |
1330 return; | 1337 return; |
1331 } | 1338 } |
1332 | 1339 |
1333 NotifyReceivedRedirect(request, info->child_id(), new_url); | 1340 NotifyReceivedRedirect(request, info->GetChildID(), new_url); |
1334 | 1341 |
1335 if (HandleExternalProtocol(info->request_id(), info->child_id(), | 1342 if (HandleExternalProtocol(info->GetRequestID(), info->GetChildID(), |
1336 info->route_id(), new_url, | 1343 info->GetRouteID(), new_url, |
1337 info->resource_type(), | 1344 info->GetResourceType(), |
1338 *request->context()->job_factory(), | 1345 *request->context()->job_factory(), |
1339 info->resource_handler())) { | 1346 info->resource_handler())) { |
1340 // The request is complete so we can remove it. | 1347 // The request is complete so we can remove it. |
1341 RemovePendingRequest(info->child_id(), info->request_id()); | 1348 RemovePendingRequest(info->GetChildID(), info->GetRequestID()); |
1342 return; | 1349 return; |
1343 } | 1350 } |
1344 | 1351 |
1345 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 1352 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
1346 PopulateResourceResponse(request, response); | 1353 PopulateResourceResponse(request, response); |
1347 if (!info->resource_handler()->OnRequestRedirected(info->request_id(), | 1354 if (!info->resource_handler()->OnRequestRedirected(info->GetRequestID(), |
1348 new_url, | 1355 new_url, |
1349 response, defer_redirect)) | 1356 response, defer_redirect)) |
1350 CancelRequestInternal(request, false); | 1357 CancelRequestInternal(request, false); |
1351 } | 1358 } |
1352 | 1359 |
1353 void ResourceDispatcherHost::OnAuthRequired( | 1360 void ResourceDispatcherHost::OnAuthRequired( |
1354 net::URLRequest* request, | 1361 net::URLRequest* request, |
1355 net::AuthChallengeInfo* auth_info) { | 1362 net::AuthChallengeInfo* auth_info) { |
1356 if (request->load_flags() & net::LOAD_DO_NOT_PROMPT_FOR_LOGIN) { | 1363 if (request->load_flags() & net::LOAD_DO_NOT_PROMPT_FOR_LOGIN) { |
1357 request->CancelAuth(); | 1364 request->CancelAuth(); |
(...skipping 20 matching lines...) Expand all Loading... |
1378 } | 1385 } |
1379 } | 1386 } |
1380 | 1387 |
1381 | 1388 |
1382 // Create a login dialog on the UI thread to get authentication data, | 1389 // Create a login dialog on the UI thread to get authentication data, |
1383 // or pull from cache and continue on the IO thread. | 1390 // or pull from cache and continue on the IO thread. |
1384 // TODO(mpcomplete): We should block the parent tab while waiting for | 1391 // TODO(mpcomplete): We should block the parent tab while waiting for |
1385 // authentication. | 1392 // authentication. |
1386 // That would also solve the problem of the net::URLRequest being cancelled | 1393 // That would also solve the problem of the net::URLRequest being cancelled |
1387 // before we receive authentication. | 1394 // before we receive authentication. |
1388 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1395 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1389 DCHECK(!info->login_delegate()) << | 1396 DCHECK(!info->login_delegate()) << |
1390 "OnAuthRequired called with login_delegate pending"; | 1397 "OnAuthRequired called with login_delegate pending"; |
1391 if (delegate_) { | 1398 if (delegate_) { |
1392 info->set_login_delegate(delegate_->CreateLoginDelegate( | 1399 info->set_login_delegate(delegate_->CreateLoginDelegate( |
1393 auth_info, request)); | 1400 auth_info, request)); |
1394 } | 1401 } |
1395 if (!info->login_delegate()) | 1402 if (!info->login_delegate()) |
1396 request->CancelAuth(); | 1403 request->CancelAuth(); |
1397 } | 1404 } |
1398 | 1405 |
1399 void ResourceDispatcherHost::OnCertificateRequested( | 1406 void ResourceDispatcherHost::OnCertificateRequested( |
1400 net::URLRequest* request, | 1407 net::URLRequest* request, |
1401 net::SSLCertRequestInfo* cert_request_info) { | 1408 net::SSLCertRequestInfo* cert_request_info) { |
1402 DCHECK(request); | 1409 DCHECK(request); |
1403 if (delegate_ && !delegate_->AcceptSSLClientCertificateRequest( | 1410 if (delegate_ && !delegate_->AcceptSSLClientCertificateRequest( |
1404 request, cert_request_info)) { | 1411 request, cert_request_info)) { |
1405 request->Cancel(); | 1412 request->Cancel(); |
1406 return; | 1413 return; |
1407 } | 1414 } |
1408 | 1415 |
1409 if (cert_request_info->client_certs.empty()) { | 1416 if (cert_request_info->client_certs.empty()) { |
1410 // No need to query the user if there are no certs to choose from. | 1417 // No need to query the user if there are no certs to choose from. |
1411 request->ContinueWithCertificate(NULL); | 1418 request->ContinueWithCertificate(NULL); |
1412 return; | 1419 return; |
1413 } | 1420 } |
1414 | 1421 |
1415 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1422 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1416 DCHECK(!info->ssl_client_auth_handler()) << | 1423 DCHECK(!info->ssl_client_auth_handler()) << |
1417 "OnCertificateRequested called with ssl_client_auth_handler pending"; | 1424 "OnCertificateRequested called with ssl_client_auth_handler pending"; |
1418 info->set_ssl_client_auth_handler( | 1425 info->set_ssl_client_auth_handler( |
1419 new SSLClientAuthHandler(request, cert_request_info)); | 1426 new SSLClientAuthHandler(request, cert_request_info)); |
1420 info->ssl_client_auth_handler()->SelectCertificate(); | 1427 info->ssl_client_auth_handler()->SelectCertificate(); |
1421 } | 1428 } |
1422 | 1429 |
1423 void ResourceDispatcherHost::OnSSLCertificateError( | 1430 void ResourceDispatcherHost::OnSSLCertificateError( |
1424 net::URLRequest* request, | 1431 net::URLRequest* request, |
1425 const net::SSLInfo& ssl_info, | 1432 const net::SSLInfo& ssl_info, |
1426 bool is_hsts_host) { | 1433 bool is_hsts_host) { |
1427 DCHECK(request); | 1434 DCHECK(request); |
1428 SSLManager::OnSSLCertificateError(this, request, ssl_info, is_hsts_host); | 1435 SSLManager::OnSSLCertificateError(this, request, ssl_info, is_hsts_host); |
1429 } | 1436 } |
1430 | 1437 |
1431 bool ResourceDispatcherHost::CanGetCookies( | 1438 bool ResourceDispatcherHost::CanGetCookies( |
1432 const net::URLRequest* request, | 1439 const net::URLRequest* request, |
1433 const net::CookieList& cookie_list) const { | 1440 const net::CookieList& cookie_list) const { |
1434 VLOG(1) << "OnGetCookies: " << request->url().spec(); | 1441 VLOG(1) << "OnGetCookies: " << request->url().spec(); |
1435 int render_process_id, render_view_id; | 1442 int render_process_id, render_view_id; |
1436 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) | 1443 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) |
1437 return false; | 1444 return false; |
1438 | 1445 |
1439 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1446 const ResourceRequestInfoImpl* info = InfoForRequest(request); |
1440 | 1447 |
1441 return content::GetContentClient()->browser()->AllowGetCookie( | 1448 return content::GetContentClient()->browser()->AllowGetCookie( |
1442 request->url(), request->first_party_for_cookies(), cookie_list, | 1449 request->url(), request->first_party_for_cookies(), cookie_list, |
1443 info->context(), render_process_id, render_view_id); | 1450 info->GetContext(), render_process_id, render_view_id); |
1444 } | 1451 } |
1445 | 1452 |
1446 bool ResourceDispatcherHost::CanSetCookie(const net::URLRequest* request, | 1453 bool ResourceDispatcherHost::CanSetCookie(const net::URLRequest* request, |
1447 const std::string& cookie_line, | 1454 const std::string& cookie_line, |
1448 net::CookieOptions* options) const { | 1455 net::CookieOptions* options) const { |
1449 VLOG(1) << "OnSetCookie: " << request->url().spec(); | 1456 VLOG(1) << "OnSetCookie: " << request->url().spec(); |
1450 | 1457 |
1451 int render_process_id, render_view_id; | 1458 int render_process_id, render_view_id; |
1452 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) | 1459 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) |
1453 return false; | 1460 return false; |
1454 | 1461 |
1455 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1462 const ResourceRequestInfoImpl* info = InfoForRequest(request); |
1456 return content::GetContentClient()->browser()->AllowSetCookie( | 1463 return content::GetContentClient()->browser()->AllowSetCookie( |
1457 request->url(), request->first_party_for_cookies(), cookie_line, | 1464 request->url(), request->first_party_for_cookies(), cookie_line, |
1458 info->context(), render_process_id, render_view_id, options); | 1465 info->GetContext(), render_process_id, render_view_id, options); |
1459 } | 1466 } |
1460 | 1467 |
1461 void ResourceDispatcherHost::OnResponseStarted(net::URLRequest* request) { | 1468 void ResourceDispatcherHost::OnResponseStarted(net::URLRequest* request) { |
1462 VLOG(1) << "OnResponseStarted: " << request->url().spec(); | 1469 VLOG(1) << "OnResponseStarted: " << request->url().spec(); |
1463 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1470 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1464 | 1471 |
1465 if (request->status().is_success()) { | 1472 if (request->status().is_success()) { |
1466 if (PauseRequestIfNeeded(info)) { | 1473 if (PauseRequestIfNeeded(info)) { |
1467 VLOG(1) << "OnResponseStarted pausing: " << request->url().spec(); | 1474 VLOG(1) << "OnResponseStarted pausing: " << request->url().spec(); |
1468 return; | 1475 return; |
1469 } | 1476 } |
1470 | 1477 |
1471 // We want to send a final upload progress message prior to sending | 1478 // We want to send a final upload progress message prior to sending |
1472 // the response complete message even if we're waiting for an ack to | 1479 // the response complete message even if we're waiting for an ack to |
1473 // to a previous upload progress message. | 1480 // to a previous upload progress message. |
(...skipping 10 matching lines...) Expand all Loading... |
1484 } | 1491 } |
1485 | 1492 |
1486 StartReading(request); | 1493 StartReading(request); |
1487 } | 1494 } |
1488 } else { | 1495 } else { |
1489 ResponseCompleted(request); | 1496 ResponseCompleted(request); |
1490 } | 1497 } |
1491 } | 1498 } |
1492 | 1499 |
1493 bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) { | 1500 bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) { |
1494 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1501 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1495 | 1502 |
1496 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 1503 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
1497 PopulateResourceResponse(request, response); | 1504 PopulateResourceResponse(request, response); |
1498 | 1505 |
1499 if (request->ssl_info().cert) { | 1506 if (request->ssl_info().cert) { |
1500 int cert_id = | 1507 int cert_id = |
1501 CertStore::GetInstance()->StoreCert(request->ssl_info().cert, | 1508 CertStore::GetInstance()->StoreCert(request->ssl_info().cert, |
1502 info->child_id()); | 1509 info->GetChildID()); |
1503 response->security_info = content::SerializeSecurityInfo( | 1510 response->security_info = content::SerializeSecurityInfo( |
1504 cert_id, request->ssl_info().cert_status, | 1511 cert_id, request->ssl_info().cert_status, |
1505 request->ssl_info().security_bits, | 1512 request->ssl_info().security_bits, |
1506 request->ssl_info().connection_status); | 1513 request->ssl_info().connection_status); |
1507 } else { | 1514 } else { |
1508 // We should not have any SSL state. | 1515 // We should not have any SSL state. |
1509 DCHECK(!request->ssl_info().cert_status && | 1516 DCHECK(!request->ssl_info().cert_status && |
1510 request->ssl_info().security_bits == -1 && | 1517 request->ssl_info().security_bits == -1 && |
1511 !request->ssl_info().connection_status); | 1518 !request->ssl_info().connection_status); |
1512 } | 1519 } |
1513 | 1520 |
1514 NotifyResponseStarted(request, info->child_id()); | 1521 NotifyResponseStarted(request, info->GetChildID()); |
1515 info->set_called_on_response_started(true); | 1522 info->set_called_on_response_started(true); |
1516 return info->resource_handler()->OnResponseStarted(info->request_id(), | 1523 return info->resource_handler()->OnResponseStarted(info->GetRequestID(), |
1517 response.get()); | 1524 response.get()); |
1518 } | 1525 } |
1519 | 1526 |
1520 void ResourceDispatcherHost::CancelRequest(int child_id, | 1527 void ResourceDispatcherHost::CancelRequest(int child_id, |
1521 int request_id, | 1528 int request_id, |
1522 bool from_renderer) { | 1529 bool from_renderer) { |
1523 GlobalRequestID id(child_id, request_id); | 1530 GlobalRequestID id(child_id, request_id); |
1524 if (from_renderer) { | 1531 if (from_renderer) { |
1525 // When the old renderer dies, it sends a message to us to cancel its | 1532 // When the old renderer dies, it sends a message to us to cancel its |
1526 // requests. | 1533 // requests. |
(...skipping 25 matching lines...) Expand all Loading... |
1552 request_id)); | 1559 request_id)); |
1553 } | 1560 } |
1554 } | 1561 } |
1555 | 1562 |
1556 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, | 1563 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, |
1557 bool from_renderer) { | 1564 bool from_renderer) { |
1558 VLOG(1) << "CancelRequest: " << request->url().spec(); | 1565 VLOG(1) << "CancelRequest: " << request->url().spec(); |
1559 | 1566 |
1560 // WebKit will send us a cancel for downloads since it no longer handles them. | 1567 // WebKit will send us a cancel for downloads since it no longer handles them. |
1561 // In this case, ignore the cancel since we handle downloads in the browser. | 1568 // In this case, ignore the cancel since we handle downloads in the browser. |
1562 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1569 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1563 if (!from_renderer || !info->is_download()) { | 1570 if (!from_renderer || !info->is_download()) { |
1564 if (info->login_delegate()) { | 1571 if (info->login_delegate()) { |
1565 info->login_delegate()->OnRequestCancelled(); | 1572 info->login_delegate()->OnRequestCancelled(); |
1566 info->set_login_delegate(NULL); | 1573 info->set_login_delegate(NULL); |
1567 } | 1574 } |
1568 if (info->ssl_client_auth_handler()) { | 1575 if (info->ssl_client_auth_handler()) { |
1569 info->ssl_client_auth_handler()->OnRequestCancelled(); | 1576 info->ssl_client_auth_handler()->OnRequestCancelled(); |
1570 info->set_ssl_client_auth_handler(NULL); | 1577 info->set_ssl_client_auth_handler(NULL); |
1571 } | 1578 } |
1572 request->Cancel(); | 1579 request->Cancel(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 request->referrer().size() + | 1620 request->referrer().size() + |
1614 request->method().size(); | 1621 request->method().size(); |
1615 | 1622 |
1616 // Note that this expression will typically be dominated by: | 1623 // Note that this expression will typically be dominated by: |
1617 // |kAvgBytesPerOutstandingRequest|. | 1624 // |kAvgBytesPerOutstandingRequest|. |
1618 return kAvgBytesPerOutstandingRequest + strings_cost; | 1625 return kAvgBytesPerOutstandingRequest + strings_cost; |
1619 } | 1626 } |
1620 | 1627 |
1621 void ResourceDispatcherHost::BeginRequestInternal(net::URLRequest* request) { | 1628 void ResourceDispatcherHost::BeginRequestInternal(net::URLRequest* request) { |
1622 DCHECK(!request->is_pending()); | 1629 DCHECK(!request->is_pending()); |
1623 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1630 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1624 | 1631 |
1625 if ((TimeTicks::Now() - last_user_gesture_time_) < | 1632 if ((TimeTicks::Now() - last_user_gesture_time_) < |
1626 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { | 1633 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { |
1627 request->set_load_flags( | 1634 request->set_load_flags( |
1628 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); | 1635 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); |
1629 } | 1636 } |
1630 | 1637 |
1631 // Add the memory estimate that starting this request will consume. | 1638 // Add the memory estimate that starting this request will consume. |
1632 info->set_memory_cost(CalculateApproximateMemoryCost(request)); | 1639 info->set_memory_cost(CalculateApproximateMemoryCost(request)); |
1633 int memory_cost = IncrementOutstandingRequestsMemoryCost(info->memory_cost(), | 1640 int memory_cost = IncrementOutstandingRequestsMemoryCost(info->memory_cost(), |
1634 info->child_id()); | 1641 info->GetChildID()); |
1635 | 1642 |
1636 // If enqueing/starting this request will exceed our per-process memory | 1643 // If enqueing/starting this request will exceed our per-process memory |
1637 // bound, abort it right away. | 1644 // bound, abort it right away. |
1638 if (memory_cost > max_outstanding_requests_cost_per_process_) { | 1645 if (memory_cost > max_outstanding_requests_cost_per_process_) { |
1639 // We call "SimulateError()" as a way of setting the net::URLRequest's | 1646 // We call "SimulateError()" as a way of setting the net::URLRequest's |
1640 // status -- it has no effect beyond this, since the request hasn't started. | 1647 // status -- it has no effect beyond this, since the request hasn't started. |
1641 request->SimulateError(net::ERR_INSUFFICIENT_RESOURCES); | 1648 request->SimulateError(net::ERR_INSUFFICIENT_RESOURCES); |
1642 | 1649 |
1643 // TODO(eroman): this is kinda funky -- we insert the unstarted request into | 1650 // TODO(eroman): this is kinda funky -- we insert the unstarted request into |
1644 // |pending_requests_| simply to please ResponseCompleted(). | 1651 // |pending_requests_| simply to please ResponseCompleted(). |
1645 GlobalRequestID global_id(info->child_id(), info->request_id()); | 1652 GlobalRequestID global_id(info->GetChildID(), info->GetRequestID()); |
1646 pending_requests_[global_id] = request; | 1653 pending_requests_[global_id] = request; |
1647 ResponseCompleted(request); | 1654 ResponseCompleted(request); |
1648 return; | 1655 return; |
1649 } | 1656 } |
1650 | 1657 |
1651 std::pair<int, int> pair_id(info->child_id(), info->route_id()); | 1658 std::pair<int, int> pair_id(info->GetChildID(), info->GetRouteID()); |
1652 BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id); | 1659 BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id); |
1653 if (iter != blocked_requests_map_.end()) { | 1660 if (iter != blocked_requests_map_.end()) { |
1654 // The request should be blocked. | 1661 // The request should be blocked. |
1655 iter->second->push_back(request); | 1662 iter->second->push_back(request); |
1656 return; | 1663 return; |
1657 } | 1664 } |
1658 | 1665 |
1659 GlobalRequestID global_id(info->child_id(), info->request_id()); | 1666 GlobalRequestID global_id(info->GetChildID(), info->GetRequestID()); |
1660 pending_requests_[global_id] = request; | 1667 pending_requests_[global_id] = request; |
1661 | 1668 |
1662 // Give the resource handlers an opportunity to delay the net::URLRequest from | 1669 // Give the resource handlers an opportunity to delay the net::URLRequest from |
1663 // being started. | 1670 // being started. |
1664 // | 1671 // |
1665 // There are three cases: | 1672 // There are three cases: |
1666 // | 1673 // |
1667 // (1) if OnWillStart() returns false, the request is cancelled (regardless | 1674 // (1) if OnWillStart() returns false, the request is cancelled (regardless |
1668 // of whether |defer_start| was set). | 1675 // of whether |defer_start| was set). |
1669 // (2) If |defer_start| was set to true, then the request is not added | 1676 // (2) If |defer_start| was set to true, then the request is not added |
1670 // into the resource queue, and will only be started in response to | 1677 // into the resource queue, and will only be started in response to |
1671 // calling StartDeferredRequest(). | 1678 // calling StartDeferredRequest(). |
1672 // (3) If |defer_start| is not set, then the request is inserted into | 1679 // (3) If |defer_start| is not set, then the request is inserted into |
1673 // the resource_queue_ (which may pause it further, or start it). | 1680 // the resource_queue_ (which may pause it further, or start it). |
1674 bool defer_start = false; | 1681 bool defer_start = false; |
1675 if (!info->resource_handler()->OnWillStart( | 1682 if (!info->resource_handler()->OnWillStart( |
1676 info->request_id(), request->url(), | 1683 info->GetRequestID(), request->url(), |
1677 &defer_start)) { | 1684 &defer_start)) { |
1678 CancelRequestInternal(request, false); | 1685 CancelRequestInternal(request, false); |
1679 return; | 1686 return; |
1680 } | 1687 } |
1681 | 1688 |
1682 if (!defer_start) | 1689 if (!defer_start) |
1683 StartRequest(request); | 1690 StartRequest(request); |
1684 } | 1691 } |
1685 | 1692 |
1686 void ResourceDispatcherHost::StartRequest(net::URLRequest* request) { | 1693 void ResourceDispatcherHost::StartRequest(net::URLRequest* request) { |
1687 request->Start(); | 1694 request->Start(); |
1688 | 1695 |
1689 // Make sure we have the load state monitor running | 1696 // Make sure we have the load state monitor running |
1690 if (!update_load_states_timer_.IsRunning()) { | 1697 if (!update_load_states_timer_.IsRunning()) { |
1691 update_load_states_timer_.Start(FROM_HERE, | 1698 update_load_states_timer_.Start(FROM_HERE, |
1692 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), | 1699 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
1693 this, &ResourceDispatcherHost::UpdateLoadStates); | 1700 this, &ResourceDispatcherHost::UpdateLoadStates); |
1694 } | 1701 } |
1695 } | 1702 } |
1696 | 1703 |
1697 bool ResourceDispatcherHost::PauseRequestIfNeeded( | 1704 bool ResourceDispatcherHost::PauseRequestIfNeeded( |
1698 ResourceDispatcherHostRequestInfo* info) { | 1705 ResourceRequestInfoImpl* info) { |
1699 if (info->pause_count() > 0) | 1706 if (info->pause_count() > 0) |
1700 info->set_is_paused(true); | 1707 info->set_is_paused(true); |
1701 return info->is_paused(); | 1708 return info->is_paused(); |
1702 } | 1709 } |
1703 | 1710 |
1704 void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) { | 1711 void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) { |
1705 PendingRequestList::iterator i = pending_requests_.find(request_id); | 1712 PendingRequestList::iterator i = pending_requests_.find(request_id); |
1706 if (i == pending_requests_.end()) // The request may have been destroyed | 1713 if (i == pending_requests_.end()) // The request may have been destroyed |
1707 return; | 1714 return; |
1708 | 1715 |
1709 net::URLRequest* request = i->second; | 1716 net::URLRequest* request = i->second; |
1710 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1717 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1711 | 1718 |
1712 // We may already be unpaused, or the pause count may have increased since we | 1719 // We may already be unpaused, or the pause count may have increased since we |
1713 // posted the task to call ResumeRequest. | 1720 // posted the task to call ResumeRequest. |
1714 if (!info->is_paused()) | 1721 if (!info->is_paused()) |
1715 return; | 1722 return; |
1716 info->set_is_paused(false); | 1723 info->set_is_paused(false); |
1717 if (PauseRequestIfNeeded(info)) | 1724 if (PauseRequestIfNeeded(info)) |
1718 return; | 1725 return; |
1719 | 1726 |
1720 VLOG(1) << "Resuming: \"" << i->second->url().spec() << "\"" | 1727 VLOG(1) << "Resuming: \"" << i->second->url().spec() << "\"" |
(...skipping 18 matching lines...) Expand all Loading... |
1739 if (Read(request, &bytes_read)) { | 1746 if (Read(request, &bytes_read)) { |
1740 OnReadCompleted(request, bytes_read); | 1747 OnReadCompleted(request, bytes_read); |
1741 } else if (!request->status().is_io_pending()) { | 1748 } else if (!request->status().is_io_pending()) { |
1742 DCHECK(!InfoForRequest(request)->is_paused()); | 1749 DCHECK(!InfoForRequest(request)->is_paused()); |
1743 // If the error is not an IO pending, then we're done reading. | 1750 // If the error is not an IO pending, then we're done reading. |
1744 ResponseCompleted(request); | 1751 ResponseCompleted(request); |
1745 } | 1752 } |
1746 } | 1753 } |
1747 | 1754 |
1748 bool ResourceDispatcherHost::Read(net::URLRequest* request, int* bytes_read) { | 1755 bool ResourceDispatcherHost::Read(net::URLRequest* request, int* bytes_read) { |
1749 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1756 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1750 DCHECK(!info->is_paused()); | 1757 DCHECK(!info->is_paused()); |
1751 | 1758 |
1752 net::IOBuffer* buf; | 1759 net::IOBuffer* buf; |
1753 int buf_size; | 1760 int buf_size; |
1754 if (!info->resource_handler()->OnWillRead(info->request_id(), | 1761 if (!info->resource_handler()->OnWillRead(info->GetRequestID(), |
1755 &buf, &buf_size, -1)) { | 1762 &buf, &buf_size, -1)) { |
1756 return false; | 1763 return false; |
1757 } | 1764 } |
1758 | 1765 |
1759 DCHECK(buf); | 1766 DCHECK(buf); |
1760 DCHECK(buf_size > 0); | 1767 DCHECK(buf_size > 0); |
1761 | 1768 |
1762 info->set_has_started_reading(true); | 1769 info->set_has_started_reading(true); |
1763 return request->Read(buf, buf_size, bytes_read); | 1770 return request->Read(buf, buf_size, bytes_read); |
1764 } | 1771 } |
1765 | 1772 |
1766 void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request, | 1773 void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request, |
1767 int bytes_read) { | 1774 int bytes_read) { |
1768 DCHECK(request); | 1775 DCHECK(request); |
1769 VLOG(1) << "OnReadCompleted: \"" << request->url().spec() << "\"" | 1776 VLOG(1) << "OnReadCompleted: \"" << request->url().spec() << "\"" |
1770 << " bytes_read = " << bytes_read; | 1777 << " bytes_read = " << bytes_read; |
1771 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1778 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1772 | 1779 |
1773 // bytes_read == -1 always implies an error, so we want to skip the pause | 1780 // bytes_read == -1 always implies an error, so we want to skip the pause |
1774 // checks and just call ResponseCompleted. | 1781 // checks and just call ResponseCompleted. |
1775 if (bytes_read == -1) { | 1782 if (bytes_read == -1) { |
1776 DCHECK(!request->status().is_success()); | 1783 DCHECK(!request->status().is_success()); |
1777 | 1784 |
1778 ResponseCompleted(request); | 1785 ResponseCompleted(request); |
1779 return; | 1786 return; |
1780 } | 1787 } |
1781 | 1788 |
(...skipping 18 matching lines...) Expand all Loading... |
1800 CompleteRead(request, &bytes_read); | 1807 CompleteRead(request, &bytes_read); |
1801 } else { | 1808 } else { |
1802 // Force the next CompleteRead / Read pair to run as a separate task. | 1809 // Force the next CompleteRead / Read pair to run as a separate task. |
1803 // This avoids a fast, large network request from monopolizing the IO | 1810 // This avoids a fast, large network request from monopolizing the IO |
1804 // thread and starving other IO operations from running. | 1811 // thread and starving other IO operations from running. |
1805 VLOG(1) << "OnReadCompleted postponing: \"" | 1812 VLOG(1) << "OnReadCompleted postponing: \"" |
1806 << request->url().spec() << "\"" | 1813 << request->url().spec() << "\"" |
1807 << " bytes_read = " << bytes_read; | 1814 << " bytes_read = " << bytes_read; |
1808 info->set_paused_read_bytes(bytes_read); | 1815 info->set_paused_read_bytes(bytes_read); |
1809 info->set_is_paused(true); | 1816 info->set_is_paused(true); |
1810 GlobalRequestID id(info->child_id(), info->request_id()); | 1817 GlobalRequestID id(info->GetChildID(), info->GetRequestID()); |
1811 MessageLoop::current()->PostTask( | 1818 MessageLoop::current()->PostTask( |
1812 FROM_HERE, | 1819 FROM_HERE, |
1813 base::Bind( | 1820 base::Bind( |
1814 &ResourceDispatcherHost::ResumeRequest, | 1821 &ResourceDispatcherHost::ResumeRequest, |
1815 weak_factory_.GetWeakPtr(), id)); | 1822 weak_factory_.GetWeakPtr(), id)); |
1816 return; | 1823 return; |
1817 } | 1824 } |
1818 } | 1825 } |
1819 } | 1826 } |
1820 | 1827 |
(...skipping 11 matching lines...) Expand all Loading... |
1832 ResponseCompleted(request); | 1839 ResponseCompleted(request); |
1833 } | 1840 } |
1834 | 1841 |
1835 bool ResourceDispatcherHost::CompleteRead(net::URLRequest* request, | 1842 bool ResourceDispatcherHost::CompleteRead(net::URLRequest* request, |
1836 int* bytes_read) { | 1843 int* bytes_read) { |
1837 if (!request || !request->status().is_success()) { | 1844 if (!request || !request->status().is_success()) { |
1838 NOTREACHED(); | 1845 NOTREACHED(); |
1839 return false; | 1846 return false; |
1840 } | 1847 } |
1841 | 1848 |
1842 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1849 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1843 if (!info->resource_handler()->OnReadCompleted(info->request_id(), | 1850 if (!info->resource_handler()->OnReadCompleted(info->GetRequestID(), |
1844 bytes_read)) { | 1851 bytes_read)) { |
1845 CancelRequestInternal(request, false); | 1852 CancelRequestInternal(request, false); |
1846 return false; | 1853 return false; |
1847 } | 1854 } |
1848 | 1855 |
1849 return *bytes_read != 0; | 1856 return *bytes_read != 0; |
1850 } | 1857 } |
1851 | 1858 |
1852 void ResourceDispatcherHost::ResponseCompleted(net::URLRequest* request) { | 1859 void ResourceDispatcherHost::ResponseCompleted(net::URLRequest* request) { |
1853 VLOG(1) << "ResponseCompleted: " << request->url().spec(); | 1860 VLOG(1) << "ResponseCompleted: " << request->url().spec(); |
1854 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1861 ResourceRequestInfoImpl* info = InfoForRequest(request); |
1855 | 1862 |
1856 // If the load for a main frame has failed, track it in a histogram, | 1863 // If the load for a main frame has failed, track it in a histogram, |
1857 // since it will probably cause the user to see an error page. | 1864 // since it will probably cause the user to see an error page. |
1858 if (!request->status().is_success() && | 1865 if (!request->status().is_success() && |
1859 info->resource_type() == ResourceType::MAIN_FRAME && | 1866 info->GetResourceType() == ResourceType::MAIN_FRAME && |
1860 request->status().error() != net::ERR_ABORTED) { | 1867 request->status().error() != net::ERR_ABORTED) { |
1861 // This enumeration has "2" appended to its name to distinguish it from | 1868 // This enumeration has "2" appended to its name to distinguish it from |
1862 // its original version. We changed the buckets at one point (added | 1869 // its original version. We changed the buckets at one point (added |
1863 // guard buckets by using CustomHistogram::ArrayToCustomRanges). | 1870 // guard buckets by using CustomHistogram::ArrayToCustomRanges). |
1864 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 1871 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
1865 "Net.ErrorCodesForMainFrame2", | 1872 "Net.ErrorCodesForMainFrame2", |
1866 -request->status().error(), | 1873 -request->status().error(), |
1867 base::CustomHistogram::ArrayToCustomRanges( | 1874 base::CustomHistogram::ArrayToCustomRanges( |
1868 kAllNetErrorCodes, arraysize(kAllNetErrorCodes))); | 1875 kAllNetErrorCodes, arraysize(kAllNetErrorCodes))); |
1869 | 1876 |
1870 if (request->url().SchemeIsSecure() && | 1877 if (request->url().SchemeIsSecure() && |
1871 request->url().host() == "www.google.com") { | 1878 request->url().host() == "www.google.com") { |
1872 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 1879 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
1873 "Net.ErrorCodesForHTTPSGoogleMainFrame", | 1880 "Net.ErrorCodesForHTTPSGoogleMainFrame", |
1874 -request->status().error(), | 1881 -request->status().error(), |
1875 base::CustomHistogram::ArrayToCustomRanges( | 1882 base::CustomHistogram::ArrayToCustomRanges( |
1876 kAllNetErrorCodes, arraysize(kAllNetErrorCodes))); | 1883 kAllNetErrorCodes, arraysize(kAllNetErrorCodes))); |
1877 } | 1884 } |
1878 } | 1885 } |
1879 | 1886 |
1880 std::string security_info; | 1887 std::string security_info; |
1881 const net::SSLInfo& ssl_info = request->ssl_info(); | 1888 const net::SSLInfo& ssl_info = request->ssl_info(); |
1882 if (ssl_info.cert != NULL) { | 1889 if (ssl_info.cert != NULL) { |
1883 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert, | 1890 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert, |
1884 info->child_id()); | 1891 info->GetChildID()); |
1885 security_info = content::SerializeSecurityInfo( | 1892 security_info = content::SerializeSecurityInfo( |
1886 cert_id, ssl_info.cert_status, ssl_info.security_bits, | 1893 cert_id, ssl_info.cert_status, ssl_info.security_bits, |
1887 ssl_info.connection_status); | 1894 ssl_info.connection_status); |
1888 } | 1895 } |
1889 | 1896 |
1890 if (info->resource_handler()->OnResponseCompleted(info->request_id(), | 1897 if (info->resource_handler()->OnResponseCompleted(info->GetRequestID(), |
1891 request->status(), | 1898 request->status(), |
1892 security_info)) { | 1899 security_info)) { |
1893 | 1900 |
1894 // The request is complete so we can remove it. | 1901 // The request is complete so we can remove it. |
1895 RemovePendingRequest(info->child_id(), info->request_id()); | 1902 RemovePendingRequest(info->GetChildID(), info->GetRequestID()); |
1896 } | 1903 } |
1897 // If the handler's OnResponseCompleted returns false, we are deferring the | 1904 // If the handler's OnResponseCompleted returns false, we are deferring the |
1898 // call until later. We will notify the world and clean up when we resume. | 1905 // call until later. We will notify the world and clean up when we resume. |
1899 } | 1906 } |
1900 | 1907 |
1901 void ResourceDispatcherHost::CallResponseCompleted(int child_id, | 1908 void ResourceDispatcherHost::CallResponseCompleted(int child_id, |
1902 int request_id) { | 1909 int request_id) { |
1903 PendingRequestList::iterator i = pending_requests_.find( | 1910 PendingRequestList::iterator i = pending_requests_.find( |
1904 GlobalRequestID(child_id, request_id)); | 1911 GlobalRequestID(child_id, request_id)); |
1905 if (i != pending_requests_.end()) | 1912 if (i != pending_requests_.end()) |
1906 ResponseCompleted(i->second); | 1913 ResponseCompleted(i->second); |
1907 } | 1914 } |
1908 | 1915 |
1909 void ResourceDispatcherHost::OnUserGesture(TabContents* tab) { | 1916 void ResourceDispatcherHost::OnUserGesture(TabContents* tab) { |
1910 last_user_gesture_time_ = TimeTicks::Now(); | 1917 last_user_gesture_time_ = TimeTicks::Now(); |
1911 } | 1918 } |
1912 | 1919 |
1913 // static | 1920 // static |
1914 ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( | 1921 ResourceRequestInfoImpl* ResourceDispatcherHost::InfoForRequest( |
1915 net::URLRequest* request) { | 1922 net::URLRequest* request) { |
1916 // Avoid writing this function twice by casting the const version. | 1923 // Avoid writing this function twice by casting the const version. |
1917 const net::URLRequest* const_request = request; | 1924 const net::URLRequest* const_request = request; |
1918 return const_cast<ResourceDispatcherHostRequestInfo*>( | 1925 return const_cast<ResourceRequestInfoImpl*>( |
1919 InfoForRequest(const_request)); | 1926 InfoForRequest(const_request)); |
1920 } | 1927 } |
1921 | 1928 |
1922 // static | 1929 // static |
1923 const ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( | 1930 const ResourceRequestInfoImpl* ResourceDispatcherHost::InfoForRequest( |
1924 const net::URLRequest* request) { | 1931 const net::URLRequest* request) { |
1925 const ResourceDispatcherHostRequestInfo* info = | 1932 return static_cast<const ResourceRequestInfoImpl*>( |
1926 static_cast<const ResourceDispatcherHostRequestInfo*>( | 1933 ResourceRequestInfo::ForRequest(request)); |
1927 request->GetUserData(NULL)); | |
1928 return info; | |
1929 } | 1934 } |
1930 | 1935 |
1931 // static | 1936 // static |
1932 bool ResourceDispatcherHost::RenderViewForRequest( | 1937 bool ResourceDispatcherHost::RenderViewForRequest( |
1933 const net::URLRequest* request, | 1938 const net::URLRequest* request, |
1934 int* render_process_host_id, | 1939 int* render_process_id, |
1935 int* render_view_host_id) { | 1940 int* render_view_id) { |
1936 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1941 const ResourceRequestInfoImpl* info = InfoForRequest(request); |
1937 if (!info) { | 1942 if (!info) { |
1938 *render_process_host_id = -1; | 1943 *render_process_id = -1; |
1939 *render_view_host_id = -1; | 1944 *render_view_id = -1; |
1940 return false; | 1945 return false; |
1941 } | 1946 } |
1942 | 1947 |
1943 // If the request is from the worker process, find a tab that owns the worker. | 1948 return info->GetAssociatedRenderView(render_process_id, render_view_id); |
1944 if (info->process_type() == content::PROCESS_TYPE_WORKER) { | |
1945 // Need to display some related UI for this network request - pick an | |
1946 // arbitrary parent to do so. | |
1947 if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker( | |
1948 info->child_id(), render_process_host_id, render_view_host_id)) { | |
1949 *render_process_host_id = -1; | |
1950 *render_view_host_id = -1; | |
1951 return false; | |
1952 } | |
1953 } else { | |
1954 *render_process_host_id = info->child_id(); | |
1955 *render_view_host_id = info->route_id(); | |
1956 } | |
1957 return true; | |
1958 } | 1949 } |
1959 | 1950 |
1960 net::URLRequest* ResourceDispatcherHost::GetURLRequest( | 1951 net::URLRequest* ResourceDispatcherHost::GetURLRequest( |
1961 const GlobalRequestID& request_id) const { | 1952 const GlobalRequestID& request_id) const { |
1962 // This should be running in the IO loop. | 1953 // This should be running in the IO loop. |
1963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1954 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1964 | 1955 |
1965 PendingRequestList::const_iterator i = pending_requests_.find(request_id); | 1956 PendingRequestList::const_iterator i = pending_requests_.find(request_id); |
1966 if (i == pending_requests_.end()) | 1957 if (i == pending_requests_.end()) |
1967 return NULL; | 1958 return NULL; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 // thread where they can be passed along to the respective RVHs. | 2076 // thread where they can be passed along to the respective RVHs. |
2086 LoadInfoMap info_map; | 2077 LoadInfoMap info_map; |
2087 | 2078 |
2088 PendingRequestList::const_iterator i; | 2079 PendingRequestList::const_iterator i; |
2089 | 2080 |
2090 // Determine the largest upload size of all requests | 2081 // Determine the largest upload size of all requests |
2091 // in each View (good chance it's zero). | 2082 // in each View (good chance it's zero). |
2092 std::map<std::pair<int, int>, uint64> largest_upload_size; | 2083 std::map<std::pair<int, int>, uint64> largest_upload_size; |
2093 for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { | 2084 for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { |
2094 net::URLRequest* request = i->second; | 2085 net::URLRequest* request = i->second; |
2095 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 2086 ResourceRequestInfoImpl* info = InfoForRequest(request); |
2096 uint64 upload_size = info->upload_size(); | 2087 uint64 upload_size = info->GetUploadSize(); |
2097 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) | 2088 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) |
2098 upload_size = 0; | 2089 upload_size = 0; |
2099 std::pair<int, int> key(info->child_id(), info->route_id()); | 2090 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); |
2100 if (upload_size && largest_upload_size[key] < upload_size) | 2091 if (upload_size && largest_upload_size[key] < upload_size) |
2101 largest_upload_size[key] = upload_size; | 2092 largest_upload_size[key] = upload_size; |
2102 } | 2093 } |
2103 | 2094 |
2104 for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { | 2095 for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { |
2105 net::URLRequest* request = i->second; | 2096 net::URLRequest* request = i->second; |
2106 net::LoadStateWithParam load_state = request->GetLoadState(); | 2097 net::LoadStateWithParam load_state = request->GetLoadState(); |
2107 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 2098 ResourceRequestInfoImpl* info = InfoForRequest(request); |
2108 std::pair<int, int> key(info->child_id(), info->route_id()); | 2099 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); |
2109 | 2100 |
2110 // We also poll for upload progress on this timer and send upload | 2101 // We also poll for upload progress on this timer and send upload |
2111 // progress ipc messages to the plugin process. | 2102 // progress ipc messages to the plugin process. |
2112 MaybeUpdateUploadProgress(info, request); | 2103 MaybeUpdateUploadProgress(info, request); |
2113 | 2104 |
2114 // If a request is uploading data, ignore all other requests so that the | 2105 // If a request is uploading data, ignore all other requests so that the |
2115 // upload progress takes priority for being shown in the status bar. | 2106 // upload progress takes priority for being shown in the status bar. |
2116 if (largest_upload_size.find(key) != largest_upload_size.end() && | 2107 if (largest_upload_size.find(key) != largest_upload_size.end() && |
2117 info->upload_size() < largest_upload_size[key]) | 2108 info->GetUploadSize() < largest_upload_size[key]) |
2118 continue; | 2109 continue; |
2119 | 2110 |
2120 net::LoadStateWithParam to_insert = load_state; | 2111 net::LoadStateWithParam to_insert = load_state; |
2121 LoadInfoMap::iterator existing = info_map.find(key); | 2112 LoadInfoMap::iterator existing = info_map.find(key); |
2122 if (existing != info_map.end()) { | 2113 if (existing != info_map.end()) { |
2123 to_insert = | 2114 to_insert = |
2124 MoreInterestingLoadState(existing->second.load_state, load_state); | 2115 MoreInterestingLoadState(existing->second.load_state, load_state); |
2125 if (to_insert.state == existing->second.load_state.state) | 2116 if (to_insert.state == existing->second.load_state.state) |
2126 continue; | 2117 continue; |
2127 } | 2118 } |
2128 LoadInfo& load_info = info_map[key]; | 2119 LoadInfo& load_info = info_map[key]; |
2129 load_info.url = request->url(); | 2120 load_info.url = request->url(); |
2130 load_info.load_state = to_insert; | 2121 load_info.load_state = to_insert; |
2131 load_info.upload_size = info->upload_size(); | 2122 load_info.upload_size = info->GetUploadSize(); |
2132 load_info.upload_position = request->GetUploadProgress(); | 2123 load_info.upload_position = request->GetUploadProgress(); |
2133 } | 2124 } |
2134 | 2125 |
2135 if (info_map.empty()) | 2126 if (info_map.empty()) |
2136 return; | 2127 return; |
2137 | 2128 |
2138 BrowserThread::PostTask( | 2129 BrowserThread::PostTask( |
2139 BrowserThread::UI, FROM_HERE, | 2130 BrowserThread::UI, FROM_HERE, |
2140 base::Bind(&LoadInfoUpdateCallback, info_map)); | 2131 base::Bind(&LoadInfoUpdateCallback, info_map)); |
2141 } | 2132 } |
2142 | 2133 |
2143 // Calls the ResourceHandler to send upload progress messages to the renderer. | 2134 // Calls the ResourceHandler to send upload progress messages to the renderer. |
2144 void ResourceDispatcherHost::MaybeUpdateUploadProgress( | 2135 void ResourceDispatcherHost::MaybeUpdateUploadProgress( |
2145 ResourceDispatcherHostRequestInfo *info, | 2136 ResourceRequestInfoImpl *info, |
2146 net::URLRequest *request) { | 2137 net::URLRequest *request) { |
2147 | 2138 |
2148 if (!info->upload_size() || info->waiting_for_upload_progress_ack()) | 2139 if (!info->GetUploadSize() || info->waiting_for_upload_progress_ack()) |
2149 return; | 2140 return; |
2150 | 2141 |
2151 uint64 size = info->upload_size(); | 2142 uint64 size = info->GetUploadSize(); |
2152 uint64 position = request->GetUploadProgress(); | 2143 uint64 position = request->GetUploadProgress(); |
2153 if (position == info->last_upload_position()) | 2144 if (position == info->last_upload_position()) |
2154 return; // no progress made since last time | 2145 return; // no progress made since last time |
2155 | 2146 |
2156 const uint64 kHalfPercentIncrements = 200; | 2147 const uint64 kHalfPercentIncrements = 200; |
2157 const TimeDelta kOneSecond = TimeDelta::FromMilliseconds(1000); | 2148 const TimeDelta kOneSecond = TimeDelta::FromMilliseconds(1000); |
2158 | 2149 |
2159 uint64 amt_since_last = position - info->last_upload_position(); | 2150 uint64 amt_since_last = position - info->last_upload_position(); |
2160 TimeDelta time_since_last = TimeTicks::Now() - info->last_upload_ticks(); | 2151 TimeDelta time_since_last = TimeTicks::Now() - info->last_upload_ticks(); |
2161 | 2152 |
2162 bool is_finished = (size == position); | 2153 bool is_finished = (size == position); |
2163 bool enough_new_progress = (amt_since_last > (size / kHalfPercentIncrements)); | 2154 bool enough_new_progress = (amt_since_last > (size / kHalfPercentIncrements)); |
2164 bool too_much_time_passed = time_since_last > kOneSecond; | 2155 bool too_much_time_passed = time_since_last > kOneSecond; |
2165 | 2156 |
2166 if (is_finished || enough_new_progress || too_much_time_passed) { | 2157 if (is_finished || enough_new_progress || too_much_time_passed) { |
2167 if (request->load_flags() & net::LOAD_ENABLE_UPLOAD_PROGRESS) { | 2158 if (request->load_flags() & net::LOAD_ENABLE_UPLOAD_PROGRESS) { |
2168 info->resource_handler()->OnUploadProgress(info->request_id(), | 2159 info->resource_handler()->OnUploadProgress(info->GetRequestID(), |
2169 position, size); | 2160 position, size); |
2170 info->set_waiting_for_upload_progress_ack(true); | 2161 info->set_waiting_for_upload_progress_ack(true); |
2171 } | 2162 } |
2172 info->set_last_upload_ticks(TimeTicks::Now()); | 2163 info->set_last_upload_ticks(TimeTicks::Now()); |
2173 info->set_last_upload_position(position); | 2164 info->set_last_upload_position(position); |
2174 } | 2165 } |
2175 } | 2166 } |
2176 | 2167 |
2177 void ResourceDispatcherHost::BlockRequestsForRoute(int child_id, int route_id) { | 2168 void ResourceDispatcherHost::BlockRequestsForRoute(int child_id, int route_id) { |
2178 std::pair<int, int> key(child_id, route_id); | 2169 std::pair<int, int> key(child_id, route_id); |
(...skipping 27 matching lines...) Expand all Loading... |
2206 BlockedRequestsList* requests = iter->second; | 2197 BlockedRequestsList* requests = iter->second; |
2207 | 2198 |
2208 // Removing the vector from the map unblocks any subsequent requests. | 2199 // Removing the vector from the map unblocks any subsequent requests. |
2209 blocked_requests_map_.erase(iter); | 2200 blocked_requests_map_.erase(iter); |
2210 | 2201 |
2211 for (BlockedRequestsList::iterator req_iter = requests->begin(); | 2202 for (BlockedRequestsList::iterator req_iter = requests->begin(); |
2212 req_iter != requests->end(); ++req_iter) { | 2203 req_iter != requests->end(); ++req_iter) { |
2213 // Remove the memory credit that we added when pushing the request onto | 2204 // Remove the memory credit that we added when pushing the request onto |
2214 // the blocked list. | 2205 // the blocked list. |
2215 net::URLRequest* request = *req_iter; | 2206 net::URLRequest* request = *req_iter; |
2216 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 2207 ResourceRequestInfoImpl* info = InfoForRequest(request); |
2217 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), | 2208 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
2218 info->child_id()); | 2209 info->GetChildID()); |
2219 if (cancel_requests) | 2210 if (cancel_requests) |
2220 delete request; | 2211 delete request; |
2221 else | 2212 else |
2222 BeginRequestInternal(request); | 2213 BeginRequestInternal(request); |
2223 } | 2214 } |
2224 | 2215 |
2225 delete requests; | 2216 delete requests; |
2226 } | 2217 } |
2227 | 2218 |
2228 bool ResourceDispatcherHost::IsValidRequest(net::URLRequest* request) { | 2219 bool ResourceDispatcherHost::IsValidRequest(net::URLRequest* request) { |
2229 if (!request) | 2220 if (!request) |
2230 return false; | 2221 return false; |
2231 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 2222 ResourceRequestInfoImpl* info = InfoForRequest(request); |
2232 return pending_requests_.find( | 2223 return pending_requests_.find( |
2233 GlobalRequestID(info->child_id(), info->request_id())) != | 2224 GlobalRequestID(info->GetChildID(), info->GetRequestID())) != |
2234 pending_requests_.end(); | 2225 pending_requests_.end(); |
2235 } | 2226 } |
2236 | 2227 |
2237 // static | 2228 // static |
2238 bool ResourceDispatcherHost::is_prefetch_enabled() { | 2229 bool ResourceDispatcherHost::is_prefetch_enabled() { |
2239 return is_prefetch_enabled_; | 2230 return is_prefetch_enabled_; |
2240 } | 2231 } |
2241 | 2232 |
2242 // static | 2233 // static |
2243 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 2234 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2277 net::URLRequest* transferred_request) { | 2268 net::URLRequest* transferred_request) { |
2278 transferred_navigations_[transferred_request_id] = transferred_request; | 2269 transferred_navigations_[transferred_request_id] = transferred_request; |
2279 | 2270 |
2280 // If a URLRequest is transferred to a new RenderViewHost, its | 2271 // If a URLRequest is transferred to a new RenderViewHost, its |
2281 // ResourceHandlers should not receive any notifications because they may | 2272 // ResourceHandlers should not receive any notifications because they may |
2282 // depend on the state of the old RVH. We set a ResourceHandler that only | 2273 // depend on the state of the old RVH. We set a ResourceHandler that only |
2283 // allows canceling requests, because on shutdown of the RDH all pending | 2274 // allows canceling requests, because on shutdown of the RDH all pending |
2284 // requests are canceled. The RVH of requests that are being transferred may | 2275 // requests are canceled. The RVH of requests that are being transferred may |
2285 // be gone by that time. If the request is resumed, the ResoureHandlers are | 2276 // be gone by that time. If the request is resumed, the ResoureHandlers are |
2286 // substituted again. | 2277 // substituted again. |
2287 ResourceDispatcherHostRequestInfo* info = InfoForRequest(transferred_request); | 2278 ResourceRequestInfoImpl* info = InfoForRequest(transferred_request); |
2288 scoped_refptr<ResourceHandler> transferred_resource_handler( | 2279 scoped_refptr<ResourceHandler> transferred_resource_handler( |
2289 new DoomedResourceHandler(info->resource_handler())); | 2280 new DoomedResourceHandler(info->resource_handler())); |
2290 info->set_resource_handler(transferred_resource_handler.get()); | 2281 info->set_resource_handler(transferred_resource_handler.get()); |
2291 } | 2282 } |
2292 | 2283 |
2293 bool ResourceDispatcherHost::IsTransferredNavigation( | 2284 bool ResourceDispatcherHost::IsTransferredNavigation( |
2294 const content::GlobalRequestID& transferred_request_id) const { | 2285 const content::GlobalRequestID& transferred_request_id) const { |
2295 return transferred_navigations_.find(transferred_request_id) != | 2286 return transferred_navigations_.find(transferred_request_id) != |
2296 transferred_navigations_.end(); | 2287 transferred_navigations_.end(); |
2297 } | 2288 } |
OLD | NEW |