| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 if (HandleExternalProtocol(request_id, child_id, route_id, | 405 if (HandleExternalProtocol(request_id, child_id, route_id, |
| 406 request_data.url, request_data.resource_type, | 406 request_data.url, request_data.resource_type, |
| 407 handler)) { | 407 handler)) { |
| 408 return; | 408 return; |
| 409 } | 409 } |
| 410 | 410 |
| 411 // Construct the request. | 411 // Construct the request. |
| 412 net::URLRequest* request = new net::URLRequest(request_data.url, this); | 412 net::URLRequest* request = new net::URLRequest(request_data.url, this); |
| 413 request->set_method(request_data.method); | 413 request->set_method(request_data.method); |
| 414 request->set_first_party_for_cookies(request_data.first_party_for_cookies); | 414 request->set_first_party_for_cookies(request_data.first_party_for_cookies); |
| 415 request->set_referrer(CommandLine::ForCurrentProcess()->HasSwitch( | 415 request->set_referrer(ReferrersEnabled() ? request_data.referrer.spec() |
| 416 switches::kNoReferrers) ? std::string() : request_data.referrer.spec()); | 416 : std::string()); |
| 417 net::HttpRequestHeaders headers; | 417 net::HttpRequestHeaders headers; |
| 418 headers.AddHeadersFromString(request_data.headers); | 418 headers.AddHeadersFromString(request_data.headers); |
| 419 request->SetExtraRequestHeaders(headers); | 419 request->SetExtraRequestHeaders(headers); |
| 420 | 420 |
| 421 int load_flags = request_data.load_flags; | 421 int load_flags = request_data.load_flags; |
| 422 // Although EV status is irrelevant to sub-frames and sub-resources, we have | 422 // Although EV status is irrelevant to sub-frames and sub-resources, we have |
| 423 // to perform EV certificate verification on all resources because an HTTP | 423 // to perform EV certificate verification on all resources because an HTTP |
| 424 // keep-alive connection created to load a sub-frame or a sub-resource could | 424 // keep-alive connection created to load a sub-frame or a sub-resource could |
| 425 // be reused to load a main frame. | 425 // be reused to load a main frame. |
| 426 load_flags |= net::LOAD_VERIFY_EV_CERT; | 426 load_flags |= net::LOAD_VERIFY_EV_CERT; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 ResourceType::MAIN_FRAME); | 715 ResourceType::MAIN_FRAME); |
| 716 } | 716 } |
| 717 | 717 |
| 718 if (!net::URLRequest::IsHandledURL(url)) { | 718 if (!net::URLRequest::IsHandledURL(url)) { |
| 719 VLOG(1) << "Download request for unsupported protocol: " | 719 VLOG(1) << "Download request for unsupported protocol: " |
| 720 << url.possibly_invalid_spec(); | 720 << url.possibly_invalid_spec(); |
| 721 return; | 721 return; |
| 722 } | 722 } |
| 723 | 723 |
| 724 request->set_method("GET"); | 724 request->set_method("GET"); |
| 725 request->set_referrer(CommandLine::ForCurrentProcess()->HasSwitch( | 725 request->set_referrer(ReferrersEnabled() ? referrer.spec() |
| 726 switches::kNoReferrers) ? std::string() : referrer.spec()); | 726 : std::string()); |
| 727 request->set_context(request_context); | 727 request->set_context(request_context); |
| 728 request->set_load_flags(request->load_flags() | | 728 request->set_load_flags(request->load_flags() | |
| 729 net::LOAD_IS_DOWNLOAD); | 729 net::LOAD_IS_DOWNLOAD); |
| 730 | 730 |
| 731 ResourceDispatcherHostRequestInfo* extra_info = | 731 ResourceDispatcherHostRequestInfo* extra_info = |
| 732 CreateRequestInfoForBrowserRequest(handler, child_id, route_id, true); | 732 CreateRequestInfoForBrowserRequest(handler, child_id, route_id, true); |
| 733 SetRequestInfo(request, extra_info); // Request takes ownership. | 733 SetRequestInfo(request, extra_info); // Request takes ownership. |
| 734 | 734 |
| 735 BeginRequestInternal(request); | 735 BeginRequestInternal(request); |
| 736 } | 736 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 756 if (!known_proto) { | 756 if (!known_proto) { |
| 757 // Since any URLs which have non-standard scheme have been filtered | 757 // Since any URLs which have non-standard scheme have been filtered |
| 758 // by save manager(see GURL::SchemeIsStandard). This situation | 758 // by save manager(see GURL::SchemeIsStandard). This situation |
| 759 // should not happen. | 759 // should not happen. |
| 760 NOTREACHED(); | 760 NOTREACHED(); |
| 761 return; | 761 return; |
| 762 } | 762 } |
| 763 | 763 |
| 764 net::URLRequest* request = new net::URLRequest(url, this); | 764 net::URLRequest* request = new net::URLRequest(url, this); |
| 765 request->set_method("GET"); | 765 request->set_method("GET"); |
| 766 request->set_referrer(CommandLine::ForCurrentProcess()->HasSwitch( | 766 request->set_referrer(ReferrersEnabled() ? referrer.spec() |
| 767 switches::kNoReferrers) ? std::string() : referrer.spec()); | 767 : std::string()); |
| 768 // So far, for saving page, we need fetch content from cache, in the | 768 // So far, for saving page, we need fetch content from cache, in the |
| 769 // future, maybe we can use a configuration to configure this behavior. | 769 // future, maybe we can use a configuration to configure this behavior. |
| 770 request->set_load_flags(net::LOAD_PREFERRING_CACHE); | 770 request->set_load_flags(net::LOAD_PREFERRING_CACHE); |
| 771 request->set_context(request_context); | 771 request->set_context(request_context); |
| 772 | 772 |
| 773 // Since we're just saving some resources we need, disallow downloading. | 773 // Since we're just saving some resources we need, disallow downloading. |
| 774 ResourceDispatcherHostRequestInfo* extra_info = | 774 ResourceDispatcherHostRequestInfo* extra_info = |
| 775 CreateRequestInfoForBrowserRequest(handler, child_id, route_id, false); | 775 CreateRequestInfoForBrowserRequest(handler, child_id, route_id, false); |
| 776 SetRequestInfo(request, extra_info); // Request takes ownership. | 776 SetRequestInfo(request, extra_info); // Request takes ownership. |
| 777 | 777 |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 | 1938 |
| 1939 bool ResourceDispatcherHost::IsPrerenderingChildRoutePair(int child_id, | 1939 bool ResourceDispatcherHost::IsPrerenderingChildRoutePair(int child_id, |
| 1940 int route_id) const { | 1940 int route_id) const { |
| 1941 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1941 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1942 std::pair<int, int> c_r_pair = std::make_pair(child_id, route_id); | 1942 std::pair<int, int> c_r_pair = std::make_pair(child_id, route_id); |
| 1943 return (prerender_child_route_pairs_.find(c_r_pair) != | 1943 return (prerender_child_route_pairs_.find(c_r_pair) != |
| 1944 prerender_child_route_pairs_.end()); | 1944 prerender_child_route_pairs_.end()); |
| 1945 } | 1945 } |
| 1946 | 1946 |
| 1947 | 1947 |
| 1948 bool ResourceDispatcherHost::ReferrersEnabled() { |
| 1949 // If we're not being called through the ResourceMessageFilter, referrers |
| 1950 // should have been stripped beforehand. |
| 1951 if (!filter_) |
| 1952 return true; |
| 1953 return filter_->referrers_enabled(); |
| 1954 } |
| 1955 |
| 1948 // static | 1956 // static |
| 1949 bool ResourceDispatcherHost::is_prefetch_enabled() { | 1957 bool ResourceDispatcherHost::is_prefetch_enabled() { |
| 1950 return is_prefetch_enabled_; | 1958 return is_prefetch_enabled_; |
| 1951 } | 1959 } |
| 1952 | 1960 |
| 1953 // static | 1961 // static |
| 1954 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1962 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1955 is_prefetch_enabled_ = value; | 1963 is_prefetch_enabled_ = value; |
| 1956 } | 1964 } |
| 1957 | 1965 |
| 1958 // static | 1966 // static |
| 1959 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1967 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |