Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 872473003: PlzNavigate: Remove the RequestNavigation IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 net::URLRequest* request) { 1841 net::URLRequest* request) {
1842 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1842 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1843 IncrementOutstandingRequestsCount(-1, info); 1843 IncrementOutstandingRequestsCount(-1, info);
1844 } 1844 }
1845 1845
1846 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1846 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1847 ResourceContext* resource_context, 1847 ResourceContext* resource_context,
1848 int64 frame_tree_node_id, 1848 int64 frame_tree_node_id,
1849 const CommonNavigationParams& params, 1849 const CommonNavigationParams& params,
1850 const NavigationRequestInfo& info, 1850 const NavigationRequestInfo& info,
1851 scoped_refptr<ResourceRequestBody> request_body,
1852 NavigationURLLoaderImplCore* loader) { 1851 NavigationURLLoaderImplCore* loader) {
1853 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1852 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1854 // browser-side navigations project. 1853 // browser-side navigations project.
1855 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1854 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1856 switches::kEnableBrowserSideNavigation)); 1855 switches::kEnableBrowserSideNavigation));
1857 1856
1858 ResourceType resource_type = info.is_main_frame ? 1857 ResourceType resource_type = info.is_main_frame ?
1859 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1858 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1860 1859
1861 if (is_shutdown_ || 1860 if (is_shutdown_ ||
1862 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1861 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
1863 // needs to be checked relative to the child that /requested/ the 1862 // needs to be checked relative to the child that /requested/ the
1864 // navigation. It's where file upload checks, etc., come in. 1863 // navigation. It's where file upload checks, etc., come in.
1865 (delegate_ && !delegate_->ShouldBeginRequest( 1864 (delegate_ && !delegate_->ShouldBeginRequest(
1866 info.navigation_params.method, 1865 info.begin_params.method,
1867 params.url, 1866 params.url,
1868 resource_type, 1867 resource_type,
1869 resource_context))) { 1868 resource_context))) {
1870 loader->NotifyRequestFailed(net::ERR_ABORTED); 1869 loader->NotifyRequestFailed(net::ERR_ABORTED);
1871 return; 1870 return;
1872 } 1871 }
1873 1872
1874 // Save the URL on the stack to help catch URLRequests which outlive their 1873 // Save the URL on the stack to help catch URLRequests which outlive their
1875 // URLRequestContexts. See https://crbug.com/90971 1874 // URLRequestContexts. See https://crbug.com/90971
1876 char url_buf[128]; 1875 char url_buf[128];
1877 base::strlcpy(url_buf, params.url.spec().c_str(), arraysize(url_buf)); 1876 base::strlcpy(url_buf, params.url.spec().c_str(), arraysize(url_buf));
1878 base::debug::Alias(url_buf); 1877 base::debug::Alias(url_buf);
1879 CHECK(ContainsKey(active_resource_contexts_, resource_context)); 1878 CHECK(ContainsKey(active_resource_contexts_, resource_context));
1880 1879
1881 const net::URLRequestContext* request_context = 1880 const net::URLRequestContext* request_context =
1882 resource_context->GetRequestContext(); 1881 resource_context->GetRequestContext();
1883 1882
1884 int load_flags = info.navigation_params.load_flags; 1883 int load_flags = info.begin_params.load_flags;
1885 load_flags |= net::LOAD_VERIFY_EV_CERT; 1884 load_flags |= net::LOAD_VERIFY_EV_CERT;
1886 if (info.is_main_frame) { 1885 if (info.is_main_frame) {
1887 load_flags |= net::LOAD_MAIN_FRAME; 1886 load_flags |= net::LOAD_MAIN_FRAME;
1888 } else { 1887 } else {
1889 load_flags |= net::LOAD_SUB_FRAME; 1888 load_flags |= net::LOAD_SUB_FRAME;
1890 } 1889 }
1891 // Add a flag to selectively bypass the data reduction proxy if the resource 1890 // Add a flag to selectively bypass the data reduction proxy if the resource
1892 // type is not an image. 1891 // type is not an image.
1893 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 1892 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
1894 1893
1895 // TODO(davidben): BuildLoadFlagsForRequest includes logic for 1894 // TODO(davidben): BuildLoadFlagsForRequest includes logic for
1896 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? 1895 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here?
1897 1896
1898 // Sync loads should have maximum priority and should be the only 1897 // Sync loads should have maximum priority and should be the only
1899 // requests that have the ignore limits flag set. 1898 // requests that have the ignore limits flag set.
1900 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); 1899 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS));
1901 1900
1902 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for 1901 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for
1903 // prerender. There may not be a renderer process yet, so we need to use the 1902 // prerender. There may not be a renderer process yet, so we need to use the
1904 // ResourceContext or something. 1903 // ResourceContext or something.
1905 scoped_ptr<net::URLRequest> new_request; 1904 scoped_ptr<net::URLRequest> new_request;
1906 new_request = request_context->CreateRequest(params.url, net::HIGHEST, 1905 new_request = request_context->CreateRequest(params.url, net::HIGHEST,
1907 nullptr, nullptr); 1906 nullptr, nullptr);
1908 1907
1909 new_request->set_method(info.navigation_params.method); 1908 new_request->set_method(info.begin_params.method);
1910 new_request->set_first_party_for_cookies( 1909 new_request->set_first_party_for_cookies(
1911 info.first_party_for_cookies); 1910 info.first_party_for_cookies);
1912 if (info.is_main_frame) { 1911 if (info.is_main_frame) {
1913 new_request->set_first_party_url_policy( 1912 new_request->set_first_party_url_policy(
1914 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); 1913 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT);
1915 } 1914 }
1916 1915
1917 SetReferrerForRequest(new_request.get(), params.referrer); 1916 SetReferrerForRequest(new_request.get(), params.referrer);
1918 1917
1919 net::HttpRequestHeaders headers; 1918 net::HttpRequestHeaders headers;
1920 headers.AddHeadersFromString(info.navigation_params.headers); 1919 headers.AddHeadersFromString(info.begin_params.headers);
1921 new_request->SetExtraRequestHeaders(headers); 1920 new_request->SetExtraRequestHeaders(headers);
1922 1921
1923 new_request->SetLoadFlags(load_flags); 1922 new_request->SetLoadFlags(load_flags);
1924 1923
1925 // Resolve elements from request_body and prepare upload data. 1924 // Resolve elements from request_body and prepare upload data.
1926 if (info.navigation_params.request_body.get()) { 1925 if (info.request_body.get()) {
1927 storage::BlobStorageContext* blob_context = GetBlobStorageContext( 1926 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1928 GetChromeBlobStorageContextForResourceContext(resource_context)); 1927 GetChromeBlobStorageContextForResourceContext(resource_context));
1929 AttachRequestBodyBlobDataHandles( 1928 AttachRequestBodyBlobDataHandles(
1930 info.navigation_params.request_body.get(), 1929 info.request_body.get(),
1931 blob_context); 1930 blob_context);
1932 // TODO(davidben): The FileSystemContext is null here. In the case where 1931 // TODO(davidben): The FileSystemContext is null here. In the case where
1933 // another renderer requested this navigation, this should be the same 1932 // another renderer requested this navigation, this should be the same
1934 // FileSystemContext passed into ShouldServiceRequest. 1933 // FileSystemContext passed into ShouldServiceRequest.
1935 new_request->set_upload(UploadDataStreamBuilder::Build( 1934 new_request->set_upload(UploadDataStreamBuilder::Build(
1936 info.navigation_params.request_body.get(), 1935 info.request_body.get(),
1937 blob_context, 1936 blob_context,
1938 nullptr, // file_system_context 1937 nullptr, // file_system_context
1939 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) 1938 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
1940 .get())); 1939 .get()));
1941 } 1940 }
1942 1941
1943 request_id_--; 1942 request_id_--;
1944 1943
1945 // Make extra info and read footer (contains request ID). 1944 // Make extra info and read footer (contains request ID).
1946 // 1945 //
(...skipping 11 matching lines...) Expand all
1958 info.parent_is_main_frame, 1957 info.parent_is_main_frame,
1959 -1, // request_data.parent_render_frame_id, 1958 -1, // request_data.parent_render_frame_id,
1960 resource_type, 1959 resource_type,
1961 params.transition, 1960 params.transition,
1962 // should_replace_current_entry. This was only maintained at layer for 1961 // should_replace_current_entry. This was only maintained at layer for
1963 // request transfers and isn't needed for browser-side navigations. 1962 // request transfers and isn't needed for browser-side navigations.
1964 false, 1963 false,
1965 false, // is download 1964 false, // is download
1966 false, // is stream 1965 false, // is stream
1967 params.allow_download, 1966 params.allow_download,
1968 info.navigation_params.has_user_gesture, 1967 info.begin_params.has_user_gesture,
1969 true, // enable_load_timing 1968 true, // enable_load_timing
1970 false, // enable_upload_progress 1969 false, // enable_upload_progress
1971 false, // do_not_prompt_for_login 1970 false, // do_not_prompt_for_login
1972 params.referrer.policy, 1971 params.referrer.policy,
1973 // TODO(davidben): This is only used for prerenders. Replace 1972 // TODO(davidben): This is only used for prerenders. Replace
1974 // is_showing with something for that. Or maybe it just comes from the 1973 // is_showing with something for that. Or maybe it just comes from the
1975 // same mechanism as the cookie one. 1974 // same mechanism as the cookie one.
1976 blink::WebPageVisibilityStateVisible, 1975 blink::WebPageVisibilityStateVisible,
1977 resource_context, 1976 resource_context,
1978 base::WeakPtr<ResourceMessageFilter>(), // filter 1977 base::WeakPtr<ResourceMessageFilter>(), // filter
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 2366
2368 // Add a flag to selectively bypass the data reduction proxy if the resource 2367 // Add a flag to selectively bypass the data reduction proxy if the resource
2369 // type is not an image. 2368 // type is not an image.
2370 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2369 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2371 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2370 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2372 2371
2373 return load_flags; 2372 return load_flags;
2374 } 2373 }
2375 2374
2376 } // namespace content 2375 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698