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_impl.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); | 485 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); |
486 | 486 |
487 const GURL& url = request->original_url(); | 487 const GURL& url = request->original_url(); |
488 | 488 |
489 // http://crbug.com/90971 | 489 // http://crbug.com/90971 |
490 char url_buf[128]; | 490 char url_buf[128]; |
491 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); | 491 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
492 base::debug::Alias(url_buf); | 492 base::debug::Alias(url_buf); |
493 CHECK(ContainsKey(active_resource_contexts_, context)); | 493 CHECK(ContainsKey(active_resource_contexts_, context)); |
494 | 494 |
495 const net::URLRequestContext* request_context = context->GetRequestContext(); | 495 const net::URLRequestContext* request_context = context->GetRequestContext(); |
erikwright (departed)
2012/06/19 21:06:22
this is now used exclusively on line 529, so do it
shalev
2012/06/20 20:13:12
Done.
| |
496 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); | 496 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); |
497 request->set_context(request_context); | |
498 int extra_load_flags = net::LOAD_IS_DOWNLOAD; | 497 int extra_load_flags = net::LOAD_IS_DOWNLOAD; |
499 if (prefer_cache) { | 498 if (prefer_cache) { |
500 // If there is upload data attached, only retrieve from cache because there | 499 // If there is upload data attached, only retrieve from cache because there |
501 // is no current mechanism to prompt the user for their consent for a | 500 // is no current mechanism to prompt the user for their consent for a |
502 // re-post. For GETs, try to retrieve data from the cache and skip | 501 // re-post. For GETs, try to retrieve data from the cache and skip |
503 // validating the entry if present. | 502 // validating the entry if present. |
504 if (request->get_upload() != NULL) | 503 if (request->get_upload() != NULL) |
505 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE; | 504 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE; |
506 else | 505 else |
507 extra_load_flags |= net::LOAD_PREFERRING_CACHE; | 506 extra_load_flags |= net::LOAD_PREFERRING_CACHE; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
796 *resource_context->GetRequestContext()->job_factory(), | 795 *resource_context->GetRequestContext()->job_factory(), |
797 handler.get())) { | 796 handler.get())) { |
798 return; | 797 return; |
799 } | 798 } |
800 | 799 |
801 // Construct the request. | 800 // Construct the request. |
802 net::URLRequest* request; | 801 net::URLRequest* request; |
803 if (deferred_request) { | 802 if (deferred_request) { |
804 request = deferred_request; | 803 request = deferred_request; |
805 } else { | 804 } else { |
806 request = new net::URLRequest(request_data.url, this); | 805 request = new net::URLRequest( |
806 request_data.url, | |
807 this, | |
808 filter_->GetURLRequestContext(request_data.resource_type)); | |
807 request->set_method(request_data.method); | 809 request->set_method(request_data.method); |
808 request->set_first_party_for_cookies(request_data.first_party_for_cookies); | 810 request->set_first_party_for_cookies(request_data.first_party_for_cookies); |
809 request->set_referrer(referrer.url.spec()); | 811 request->set_referrer(referrer.url.spec()); |
810 webkit_glue::ConfigureURLRequestForReferrerPolicy(request, referrer.policy); | 812 webkit_glue::ConfigureURLRequestForReferrerPolicy(request, referrer.policy); |
811 net::HttpRequestHeaders headers; | 813 net::HttpRequestHeaders headers; |
812 headers.AddHeadersFromString(request_data.headers); | 814 headers.AddHeadersFromString(request_data.headers); |
813 request->SetExtraRequestHeaders(headers); | 815 request->SetExtraRequestHeaders(headers); |
814 } | 816 } |
815 | 817 |
816 int load_flags = request_data.load_flags; | 818 int load_flags = request_data.load_flags; |
(...skipping 26 matching lines...) Expand all Loading... | |
843 // Raw headers are sensitive, as they include Cookie/Set-Cookie, so only | 845 // Raw headers are sensitive, as they include Cookie/Set-Cookie, so only |
844 // allow requesting them if requester has ReadRawCookies permission. | 846 // allow requesting them if requester has ReadRawCookies permission. |
845 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 847 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
846 && !policy->CanReadRawCookies(child_id)) { | 848 && !policy->CanReadRawCookies(child_id)) { |
847 VLOG(1) << "Denied unauthorized request for raw headers"; | 849 VLOG(1) << "Denied unauthorized request for raw headers"; |
848 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 850 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
849 } | 851 } |
850 | 852 |
851 request->set_load_flags(load_flags); | 853 request->set_load_flags(load_flags); |
852 | 854 |
853 request->set_context( | |
854 filter_->GetURLRequestContext(request_data.resource_type)); | |
855 request->set_priority(DetermineRequestPriority(request_data.resource_type)); | 855 request->set_priority(DetermineRequestPriority(request_data.resource_type)); |
856 | 856 |
857 // Set upload data. | 857 // Set upload data. |
858 uint64 upload_size = 0; | 858 uint64 upload_size = 0; |
859 if (request_data.upload_data) { | 859 if (request_data.upload_data) { |
860 request->set_upload(request_data.upload_data); | 860 request->set_upload(request_data.upload_data); |
861 // This results in performing file IO. crbug.com/112607. | 861 // This results in performing file IO. crbug.com/112607. |
862 base::ThreadRestrictions::ScopedAllowIO allow_io; | 862 base::ThreadRestrictions::ScopedAllowIO allow_io; |
863 upload_size = request_data.upload_data->GetContentLengthSync(); | 863 upload_size = request_data.upload_data->GetContentLengthSync(); |
864 } | 864 } |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1166 bool known_proto = | 1166 bool known_proto = |
1167 request_context->job_factory()->IsHandledURL(url); | 1167 request_context->job_factory()->IsHandledURL(url); |
1168 if (!known_proto) { | 1168 if (!known_proto) { |
1169 // Since any URLs which have non-standard scheme have been filtered | 1169 // Since any URLs which have non-standard scheme have been filtered |
1170 // by save manager(see GURL::SchemeIsStandard). This situation | 1170 // by save manager(see GURL::SchemeIsStandard). This situation |
1171 // should not happen. | 1171 // should not happen. |
1172 NOTREACHED(); | 1172 NOTREACHED(); |
1173 return; | 1173 return; |
1174 } | 1174 } |
1175 | 1175 |
1176 net::URLRequest* request = new net::URLRequest(url, this); | 1176 net::URLRequest* request = new net::URLRequest(url, |
1177 this, | |
1178 context->GetRequestContext()); | |
erikwright (departed)
2012/06/19 21:06:22
access this via request_context local variable.
shalev
2012/06/20 20:13:12
Done.
| |
1177 request->set_method("GET"); | 1179 request->set_method("GET"); |
1178 request->set_referrer(MaybeStripReferrer(referrer.url).spec()); | 1180 request->set_referrer(MaybeStripReferrer(referrer.url).spec()); |
1179 webkit_glue::ConfigureURLRequestForReferrerPolicy(request, referrer.policy); | 1181 webkit_glue::ConfigureURLRequestForReferrerPolicy(request, referrer.policy); |
1180 // So far, for saving page, we need fetch content from cache, in the | 1182 // So far, for saving page, we need fetch content from cache, in the |
1181 // future, maybe we can use a configuration to configure this behavior. | 1183 // future, maybe we can use a configuration to configure this behavior. |
1182 request->set_load_flags(net::LOAD_PREFERRING_CACHE); | 1184 request->set_load_flags(net::LOAD_PREFERRING_CACHE); |
1183 request->set_context(context->GetRequestContext()); | |
1184 | 1185 |
1185 // Since we're just saving some resources we need, disallow downloading. | 1186 // Since we're just saving some resources we need, disallow downloading. |
1186 ResourceRequestInfoImpl* extra_info = | 1187 ResourceRequestInfoImpl* extra_info = |
1187 CreateRequestInfo(handler.Pass(), child_id, route_id, false, context); | 1188 CreateRequestInfo(handler.Pass(), child_id, route_id, false, context); |
1188 extra_info->AssociateWithRequest(request); // Request takes ownership. | 1189 extra_info->AssociateWithRequest(request); // Request takes ownership. |
1189 | 1190 |
1190 BeginRequestInternal(request); | 1191 BeginRequestInternal(request); |
1191 } | 1192 } |
1192 | 1193 |
1193 void ResourceDispatcherHostImpl::FollowDeferredRedirect( | 1194 void ResourceDispatcherHostImpl::FollowDeferredRedirect( |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2359 return allow_cross_origin_auth_prompt_; | 2360 return allow_cross_origin_auth_prompt_; |
2360 } | 2361 } |
2361 | 2362 |
2362 bool ResourceDispatcherHostImpl::IsTransferredNavigation( | 2363 bool ResourceDispatcherHostImpl::IsTransferredNavigation( |
2363 const GlobalRequestID& transferred_request_id) const { | 2364 const GlobalRequestID& transferred_request_id) const { |
2364 return transferred_navigations_.find(transferred_request_id) != | 2365 return transferred_navigations_.find(transferred_request_id) != |
2365 transferred_navigations_.end(); | 2366 transferred_navigations_.end(); |
2366 } | 2367 } |
2367 | 2368 |
2368 } // namespace content | 2369 } // namespace content |
OLD | NEW |