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/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 // Allow the observer to block/handle the request. | 1146 // Allow the observer to block/handle the request. |
1147 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, | 1147 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, |
1148 request_data.url, | 1148 request_data.url, |
1149 request_data.resource_type, | 1149 request_data.resource_type, |
1150 resource_context)) { | 1150 resource_context)) { |
1151 AbortRequestBeforeItStarts(filter_, sync_result, request_id); | 1151 AbortRequestBeforeItStarts(filter_, sync_result, request_id); |
1152 return; | 1152 return; |
1153 } | 1153 } |
1154 | 1154 |
1155 // Construct the request. | 1155 // Construct the request. |
1156 net::CookieStore* cookie_store = | |
1157 GetContentClient()->browser()->OverrideCookieStoreForRenderProcess( | |
1158 child_id); | |
1159 scoped_ptr<net::URLRequest> new_request; | 1156 scoped_ptr<net::URLRequest> new_request; |
1160 new_request = request_context->CreateRequest( | 1157 new_request = request_context->CreateRequest( |
1161 request_data.url, request_data.priority, NULL, cookie_store); | 1158 request_data.url, request_data.priority, NULL, NULL); |
1162 | 1159 |
1163 new_request->set_method(request_data.method); | 1160 new_request->set_method(request_data.method); |
1164 new_request->set_first_party_for_cookies( | 1161 new_request->set_first_party_for_cookies( |
1165 request_data.first_party_for_cookies); | 1162 request_data.first_party_for_cookies); |
1166 | 1163 |
1167 // If the request is a MAIN_FRAME request, the first-party URL gets updated on | 1164 // If the request is a MAIN_FRAME request, the first-party URL gets updated on |
1168 // redirects. | 1165 // redirects. |
1169 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { | 1166 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { |
1170 new_request->set_first_party_url_policy( | 1167 new_request->set_first_party_url_policy( |
1171 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 1168 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 bool known_proto = | 1584 bool known_proto = |
1588 request_context->job_factory()->IsHandledURL(url); | 1585 request_context->job_factory()->IsHandledURL(url); |
1589 if (!known_proto) { | 1586 if (!known_proto) { |
1590 // Since any URLs which have non-standard scheme have been filtered | 1587 // Since any URLs which have non-standard scheme have been filtered |
1591 // by save manager(see GURL::SchemeIsStandard). This situation | 1588 // by save manager(see GURL::SchemeIsStandard). This situation |
1592 // should not happen. | 1589 // should not happen. |
1593 NOTREACHED(); | 1590 NOTREACHED(); |
1594 return; | 1591 return; |
1595 } | 1592 } |
1596 | 1593 |
1597 net::CookieStore* cookie_store = | |
1598 GetContentClient()->browser()->OverrideCookieStoreForRenderProcess( | |
1599 child_id); | |
1600 scoped_ptr<net::URLRequest> request( | 1594 scoped_ptr<net::URLRequest> request( |
1601 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL, | 1595 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL, NULL)); |
1602 cookie_store)); | |
1603 | |
1604 request->set_method("GET"); | 1596 request->set_method("GET"); |
1605 SetReferrerForRequest(request.get(), referrer); | 1597 SetReferrerForRequest(request.get(), referrer); |
1606 | 1598 |
1607 // So far, for saving page, we need fetch content from cache, in the | 1599 // So far, for saving page, we need fetch content from cache, in the |
1608 // future, maybe we can use a configuration to configure this behavior. | 1600 // future, maybe we can use a configuration to configure this behavior. |
1609 request->SetLoadFlags(net::LOAD_PREFERRING_CACHE); | 1601 request->SetLoadFlags(net::LOAD_PREFERRING_CACHE); |
1610 | 1602 |
1611 // Since we're just saving some resources we need, disallow downloading. | 1603 // Since we're just saving some resources we need, disallow downloading. |
1612 ResourceRequestInfoImpl* extra_info = | 1604 ResourceRequestInfoImpl* extra_info = |
1613 CreateRequestInfo(child_id, route_id, false, context); | 1605 CreateRequestInfo(child_id, route_id, false, context); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 // type is not an image. | 1888 // type is not an image. |
1897 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 1889 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
1898 | 1890 |
1899 // TODO(davidben): BuildLoadFlagsForRequest includes logic for | 1891 // TODO(davidben): BuildLoadFlagsForRequest includes logic for |
1900 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? | 1892 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? |
1901 | 1893 |
1902 // Sync loads should have maximum priority and should be the only | 1894 // Sync loads should have maximum priority and should be the only |
1903 // requests that have the ignore limits flag set. | 1895 // requests that have the ignore limits flag set. |
1904 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); | 1896 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); |
1905 | 1897 |
1906 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for | |
1907 // prerender. There may not be a renderer process yet, so we need to use the | |
1908 // ResourceContext or something. | |
1909 scoped_ptr<net::URLRequest> new_request; | 1898 scoped_ptr<net::URLRequest> new_request; |
1910 new_request = request_context->CreateRequest( | 1899 new_request = request_context->CreateRequest( |
1911 info.common_params.url, net::HIGHEST, nullptr, nullptr); | 1900 info.common_params.url, net::HIGHEST, nullptr, nullptr); |
1912 | 1901 |
1913 new_request->set_method(info.begin_params.method); | 1902 new_request->set_method(info.begin_params.method); |
1914 new_request->set_first_party_for_cookies( | 1903 new_request->set_first_party_for_cookies( |
1915 info.first_party_for_cookies); | 1904 info.first_party_for_cookies); |
1916 if (info.is_main_frame) { | 1905 if (info.is_main_frame) { |
1917 new_request->set_first_party_url_policy( | 1906 new_request->set_first_party_url_policy( |
1918 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 1907 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 | 2346 |
2358 // Add a flag to selectively bypass the data reduction proxy if the resource | 2347 // Add a flag to selectively bypass the data reduction proxy if the resource |
2359 // type is not an image. | 2348 // type is not an image. |
2360 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2349 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
2361 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2350 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2362 | 2351 |
2363 return load_flags; | 2352 return load_flags; |
2364 } | 2353 } |
2365 | 2354 |
2366 } // namespace content | 2355 } // namespace content |
OLD | NEW |