| 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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 ResourceType::Type resource_type) { | 870 ResourceType::Type resource_type) { |
| 871 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) | 871 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) |
| 872 return; | 872 return; |
| 873 | 873 |
| 874 filter_->GetURLRequestContext(resource_type)->http_transaction_factory()-> | 874 filter_->GetURLRequestContext(resource_type)->http_transaction_factory()-> |
| 875 GetCache()->OnExternalCacheHit(url, http_method); | 875 GetCache()->OnExternalCacheHit(url, http_method); |
| 876 } | 876 } |
| 877 | 877 |
| 878 // We are explicitly forcing the download of 'url'. | 878 // We are explicitly forcing the download of 'url'. |
| 879 void ResourceDispatcherHost::BeginDownload( | 879 void ResourceDispatcherHost::BeginDownload( |
| 880 net::URLRequest* request, | 880 scoped_ptr<net::URLRequest> request, |
| 881 const DownloadSaveInfo& save_info, | 881 const DownloadSaveInfo& save_info, |
| 882 bool prompt_for_save_location, | 882 bool prompt_for_save_location, |
| 883 const DownloadResourceHandler::OnStartedCallback& started_cb, | 883 const DownloadResourceHandler::OnStartedCallback& started_cb, |
| 884 int child_id, | 884 int child_id, |
| 885 int route_id, | 885 int route_id, |
| 886 const content::ResourceContext& context) { | 886 const content::ResourceContext& context) { |
| 887 scoped_ptr<net::URLRequest> delete_request(request); | |
| 888 // If DownloadResourceHandler is not begun, then started_cb must be called | 887 // If DownloadResourceHandler is not begun, then started_cb must be called |
| 889 // here in order to satisfy its semantics. | 888 // here in order to satisfy its semantics. |
| 890 if (is_shutdown_) { | 889 if (is_shutdown_) { |
| 891 if (!started_cb.is_null()) | 890 if (!started_cb.is_null()) |
| 892 started_cb.Run(DownloadId::Invalid(), net::ERR_INSUFFICIENT_RESOURCES); | 891 started_cb.Run(DownloadId::Invalid(), net::ERR_INSUFFICIENT_RESOURCES); |
| 893 // Time and RDH are resources that are running out. | 892 // Time and RDH are resources that are running out. |
| 894 return; | 893 return; |
| 895 } | 894 } |
| 896 const GURL& url = request->original_url(); | 895 const GURL& url = request->original_url(); |
| 897 const net::URLRequestContext* request_context = context.request_context(); | 896 const net::URLRequestContext* request_context = context.request_context(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 916 DownloadId dl_id = context.download_id_factory()->GetNextId(); | 915 DownloadId dl_id = context.download_id_factory()->GetNextId(); |
| 917 | 916 |
| 918 scoped_refptr<ResourceHandler> handler( | 917 scoped_refptr<ResourceHandler> handler( |
| 919 new DownloadResourceHandler(this, | 918 new DownloadResourceHandler(this, |
| 920 child_id, | 919 child_id, |
| 921 route_id, | 920 route_id, |
| 922 request_id_, | 921 request_id_, |
| 923 url, | 922 url, |
| 924 dl_id, | 923 dl_id, |
| 925 download_file_manager_.get(), | 924 download_file_manager_.get(), |
| 926 request, | 925 request.get(), |
| 927 prompt_for_save_location, | 926 prompt_for_save_location, |
| 928 started_cb, | 927 started_cb, |
| 929 save_info)); | 928 save_info)); |
| 930 | 929 |
| 931 if (delegate_) { | 930 if (delegate_) { |
| 932 handler = delegate_->DownloadStarting( | 931 handler = delegate_->DownloadStarting( |
| 933 handler, context, request, child_id, route_id, request_id_, true); | 932 handler, context, request.get(), |
| 933 child_id, route_id, request_id_, true); |
| 934 } | 934 } |
| 935 | 935 |
| 936 if (!request_context->job_factory()->IsHandledURL(url)) { | 936 if (!request_context->job_factory()->IsHandledURL(url)) { |
| 937 VLOG(1) << "Download request for unsupported protocol: " | 937 VLOG(1) << "Download request for unsupported protocol: " |
| 938 << url.possibly_invalid_spec(); | 938 << url.possibly_invalid_spec(); |
| 939 if (!started_cb.is_null()) | 939 if (!started_cb.is_null()) |
| 940 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED); | 940 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED); |
| 941 return; | 941 return; |
| 942 } | 942 } |
| 943 | 943 |
| 944 ResourceDispatcherHostRequestInfo* extra_info = | 944 ResourceDispatcherHostRequestInfo* extra_info = |
| 945 CreateRequestInfo(handler, child_id, route_id, true, context); | 945 CreateRequestInfo(handler, child_id, route_id, true, context); |
| 946 SetRequestInfo(request, extra_info); // Request takes ownership. | 946 SetRequestInfo(request.get(), extra_info); // Request takes ownership. |
| 947 | 947 |
| 948 BeginRequestInternal(delete_request.release()); | 948 BeginRequestInternal(request.release()); |
| 949 } | 949 } |
| 950 | 950 |
| 951 // This function is only used for saving feature. | 951 // This function is only used for saving feature. |
| 952 void ResourceDispatcherHost::BeginSaveFile( | 952 void ResourceDispatcherHost::BeginSaveFile( |
| 953 const GURL& url, | 953 const GURL& url, |
| 954 const GURL& referrer, | 954 const GURL& referrer, |
| 955 int child_id, | 955 int child_id, |
| 956 int route_id, | 956 int route_id, |
| 957 const content::ResourceContext& context) { | 957 const content::ResourceContext& context) { |
| 958 if (is_shutdown_) | 958 if (is_shutdown_) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 if (i == pending_requests_.end() || !i->second->status().is_success()) { | 1002 if (i == pending_requests_.end() || !i->second->status().is_success()) { |
| 1003 DLOG(WARNING) << "FollowDeferredRedirect for invalid request"; | 1003 DLOG(WARNING) << "FollowDeferredRedirect for invalid request"; |
| 1004 return; | 1004 return; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 if (has_new_first_party_for_cookies) | 1007 if (has_new_first_party_for_cookies) |
| 1008 i->second->set_first_party_for_cookies(new_first_party_for_cookies); | 1008 i->second->set_first_party_for_cookies(new_first_party_for_cookies); |
| 1009 i->second->FollowDeferredRedirect(); | 1009 i->second->FollowDeferredRedirect(); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void ResourceDispatcherHost::StartDeferredRequest(int process_unique_id, | 1012 void ResourceDispatcherHost::StartDeferredRequest(int child_id, |
| 1013 int request_id) { | 1013 int request_id) { |
| 1014 GlobalRequestID global_id(process_unique_id, request_id); | 1014 GlobalRequestID global_id(child_id, request_id); |
| 1015 PendingRequestList::iterator i = pending_requests_.find(global_id); | 1015 PendingRequestList::iterator i = pending_requests_.find(global_id); |
| 1016 if (i == pending_requests_.end()) { | 1016 if (i == pending_requests_.end()) { |
| 1017 // The request may have been destroyed | 1017 // The request may have been destroyed |
| 1018 LOG(WARNING) << "Trying to resume a non-existent request (" | 1018 LOG(WARNING) << "Trying to resume a non-existent request (" |
| 1019 << process_unique_id << ", " << request_id << ")"; | 1019 << child_id << ", " << request_id << ")"; |
| 1020 return; | 1020 return; |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 // TODO(eroman): are there other considerations for paused or blocked | 1023 // TODO(eroman): are there other considerations for paused or blocked |
| 1024 // requests? | 1024 // requests? |
| 1025 | 1025 |
| 1026 net::URLRequest* request = i->second; | 1026 net::URLRequest* request = i->second; |
| 1027 InsertIntoResourceQueue(request, *InfoForRequest(request)); | 1027 InsertIntoResourceQueue(request, *InfoForRequest(request)); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 const GlobalRequestID& transferred_request_id, | 2253 const GlobalRequestID& transferred_request_id, |
| 2254 net::URLRequest* ransferred_request) { | 2254 net::URLRequest* ransferred_request) { |
| 2255 transferred_navigations_[transferred_request_id] = ransferred_request; | 2255 transferred_navigations_[transferred_request_id] = ransferred_request; |
| 2256 } | 2256 } |
| 2257 | 2257 |
| 2258 bool ResourceDispatcherHost::IsTransferredNavigation( | 2258 bool ResourceDispatcherHost::IsTransferredNavigation( |
| 2259 const content::GlobalRequestID& transferred_request_id) const { | 2259 const content::GlobalRequestID& transferred_request_id) const { |
| 2260 return transferred_navigations_.find(transferred_request_id) != | 2260 return transferred_navigations_.find(transferred_request_id) != |
| 2261 transferred_navigations_.end(); | 2261 transferred_navigations_.end(); |
| 2262 } | 2262 } |
| OLD | NEW |