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

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: Addressed nits + fix compilation error Created 5 years, 10 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
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1841
1842 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1842 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1843 net::URLRequest* request) { 1843 net::URLRequest* request) {
1844 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1844 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1845 IncrementOutstandingRequestsCount(-1, info); 1845 IncrementOutstandingRequestsCount(-1, info);
1846 } 1846 }
1847 1847
1848 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1848 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1849 ResourceContext* resource_context, 1849 ResourceContext* resource_context,
1850 int64 frame_tree_node_id, 1850 int64 frame_tree_node_id,
1851 const CommonNavigationParams& params,
1852 const NavigationRequestInfo& info, 1851 const NavigationRequestInfo& info,
1853 scoped_refptr<ResourceRequestBody> request_body,
1854 NavigationURLLoaderImplCore* loader) { 1852 NavigationURLLoaderImplCore* loader) {
1855 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1853 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1856 // browser-side navigations project. 1854 // browser-side navigations project.
1857 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1855 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1858 switches::kEnableBrowserSideNavigation)); 1856 switches::kEnableBrowserSideNavigation));
1859 1857
1860 ResourceType resource_type = info.is_main_frame ? 1858 ResourceType resource_type = info.is_main_frame ?
1861 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1859 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1862 1860
1863 if (is_shutdown_ || 1861 if (is_shutdown_ ||
1864 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1862 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
1865 // needs to be checked relative to the child that /requested/ the 1863 // needs to be checked relative to the child that /requested/ the
1866 // navigation. It's where file upload checks, etc., come in. 1864 // navigation. It's where file upload checks, etc., come in.
1867 (delegate_ && !delegate_->ShouldBeginRequest( 1865 (delegate_ && !delegate_->ShouldBeginRequest(
1868 info.navigation_params.method, 1866 info.begin_params.method,
1869 params.url, 1867 info.common_params.url,
1870 resource_type, 1868 resource_type,
1871 resource_context))) { 1869 resource_context))) {
1872 loader->NotifyRequestFailed(net::ERR_ABORTED); 1870 loader->NotifyRequestFailed(net::ERR_ABORTED);
1873 return; 1871 return;
1874 } 1872 }
1875 1873
1876 // Save the URL on the stack to help catch URLRequests which outlive their 1874 // Save the URL on the stack to help catch URLRequests which outlive their
1877 // URLRequestContexts. See https://crbug.com/90971 1875 // URLRequestContexts. See https://crbug.com/90971
1878 char url_buf[128]; 1876 char url_buf[128];
1879 base::strlcpy(url_buf, params.url.spec().c_str(), arraysize(url_buf)); 1877 base::strlcpy(
1878 url_buf, info.common_params.url.spec().c_str(), arraysize(url_buf));
1880 base::debug::Alias(url_buf); 1879 base::debug::Alias(url_buf);
1881 CHECK(ContainsKey(active_resource_contexts_, resource_context)); 1880 CHECK(ContainsKey(active_resource_contexts_, resource_context));
1882 1881
1883 const net::URLRequestContext* request_context = 1882 const net::URLRequestContext* request_context =
1884 resource_context->GetRequestContext(); 1883 resource_context->GetRequestContext();
1885 1884
1886 int load_flags = info.navigation_params.load_flags; 1885 int load_flags = info.begin_params.load_flags;
1887 load_flags |= net::LOAD_VERIFY_EV_CERT; 1886 load_flags |= net::LOAD_VERIFY_EV_CERT;
1888 if (info.is_main_frame) { 1887 if (info.is_main_frame) {
1889 load_flags |= net::LOAD_MAIN_FRAME; 1888 load_flags |= net::LOAD_MAIN_FRAME;
1890 } else { 1889 } else {
1891 load_flags |= net::LOAD_SUB_FRAME; 1890 load_flags |= net::LOAD_SUB_FRAME;
1892 } 1891 }
1893 // Add a flag to selectively bypass the data reduction proxy if the resource 1892 // Add a flag to selectively bypass the data reduction proxy if the resource
1894 // type is not an image. 1893 // type is not an image.
1895 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 1894 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
1896 1895
1897 // TODO(davidben): BuildLoadFlagsForRequest includes logic for 1896 // TODO(davidben): BuildLoadFlagsForRequest includes logic for
1898 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? 1897 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here?
1899 1898
1900 // Sync loads should have maximum priority and should be the only 1899 // Sync loads should have maximum priority and should be the only
1901 // requests that have the ignore limits flag set. 1900 // requests that have the ignore limits flag set.
1902 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); 1901 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS));
1903 1902
1904 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for 1903 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for
1905 // prerender. There may not be a renderer process yet, so we need to use the 1904 // prerender. There may not be a renderer process yet, so we need to use the
1906 // ResourceContext or something. 1905 // ResourceContext or something.
1907 scoped_ptr<net::URLRequest> new_request; 1906 scoped_ptr<net::URLRequest> new_request;
1908 new_request = request_context->CreateRequest(params.url, net::HIGHEST, 1907 new_request = request_context->CreateRequest(
1909 nullptr, nullptr); 1908 info.common_params.url, net::HIGHEST, nullptr, nullptr);
1910 1909
1911 new_request->set_method(info.navigation_params.method); 1910 new_request->set_method(info.begin_params.method);
1912 new_request->set_first_party_for_cookies( 1911 new_request->set_first_party_for_cookies(
1913 info.first_party_for_cookies); 1912 info.first_party_for_cookies);
1914 if (info.is_main_frame) { 1913 if (info.is_main_frame) {
1915 new_request->set_first_party_url_policy( 1914 new_request->set_first_party_url_policy(
1916 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); 1915 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT);
1917 } 1916 }
1918 1917
1919 SetReferrerForRequest(new_request.get(), params.referrer); 1918 SetReferrerForRequest(new_request.get(), info.common_params.referrer);
1920 1919
1921 net::HttpRequestHeaders headers; 1920 net::HttpRequestHeaders headers;
1922 headers.AddHeadersFromString(info.navigation_params.headers); 1921 headers.AddHeadersFromString(info.begin_params.headers);
1923 new_request->SetExtraRequestHeaders(headers); 1922 new_request->SetExtraRequestHeaders(headers);
1924 1923
1925 new_request->SetLoadFlags(load_flags); 1924 new_request->SetLoadFlags(load_flags);
1926 1925
1927 // Resolve elements from request_body and prepare upload data. 1926 // Resolve elements from request_body and prepare upload data.
1928 if (info.navigation_params.request_body.get()) { 1927 if (info.request_body.get()) {
1929 storage::BlobStorageContext* blob_context = GetBlobStorageContext( 1928 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1930 GetChromeBlobStorageContextForResourceContext(resource_context)); 1929 GetChromeBlobStorageContextForResourceContext(resource_context));
1931 AttachRequestBodyBlobDataHandles( 1930 AttachRequestBodyBlobDataHandles(
1932 info.navigation_params.request_body.get(), 1931 info.request_body.get(),
1933 blob_context); 1932 blob_context);
1934 // TODO(davidben): The FileSystemContext is null here. In the case where 1933 // TODO(davidben): The FileSystemContext is null here. In the case where
1935 // another renderer requested this navigation, this should be the same 1934 // another renderer requested this navigation, this should be the same
1936 // FileSystemContext passed into ShouldServiceRequest. 1935 // FileSystemContext passed into ShouldServiceRequest.
1937 new_request->set_upload(UploadDataStreamBuilder::Build( 1936 new_request->set_upload(UploadDataStreamBuilder::Build(
1938 info.navigation_params.request_body.get(), 1937 info.request_body.get(),
1939 blob_context, 1938 blob_context,
1940 nullptr, // file_system_context 1939 nullptr, // file_system_context
1941 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) 1940 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
1942 .get())); 1941 .get()));
1943 } 1942 }
1944 1943
1945 request_id_--; 1944 request_id_--;
1946 1945
1947 // Make extra info and read footer (contains request ID). 1946 // Make extra info and read footer (contains request ID).
1948 // 1947 //
1949 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so 1948 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so
1950 // that IO thread -> UI thread hops will work. 1949 // that IO thread -> UI thread hops will work.
1951 ResourceRequestInfoImpl* extra_info = 1950 ResourceRequestInfoImpl* extra_info =
1952 new ResourceRequestInfoImpl( 1951 new ResourceRequestInfoImpl(
1953 PROCESS_TYPE_BROWSER, 1952 PROCESS_TYPE_BROWSER,
1954 -1, // child_id 1953 -1, // child_id
1955 -1, // route_id 1954 -1, // route_id
1956 -1, // request_data.origin_pid, 1955 -1, // request_data.origin_pid,
1957 request_id_, 1956 request_id_,
1958 -1, // request_data.render_frame_id, 1957 -1, // request_data.render_frame_id,
1959 info.is_main_frame, 1958 info.is_main_frame,
1960 info.parent_is_main_frame, 1959 info.parent_is_main_frame,
1961 -1, // request_data.parent_render_frame_id, 1960 -1, // request_data.parent_render_frame_id,
1962 resource_type, 1961 resource_type,
1963 params.transition, 1962 info.common_params.transition,
1964 // should_replace_current_entry. This was only maintained at layer for 1963 // should_replace_current_entry. This was only maintained at layer for
1965 // request transfers and isn't needed for browser-side navigations. 1964 // request transfers and isn't needed for browser-side navigations.
1966 false, 1965 false,
1967 false, // is download 1966 false, // is download
1968 false, // is stream 1967 false, // is stream
1969 params.allow_download, 1968 info.common_params.allow_download,
1970 info.navigation_params.has_user_gesture, 1969 info.begin_params.has_user_gesture,
1971 true, // enable_load_timing 1970 true, // enable_load_timing
1972 false, // enable_upload_progress 1971 false, // enable_upload_progress
1973 false, // do_not_prompt_for_login 1972 false, // do_not_prompt_for_login
1974 params.referrer.policy, 1973 info.common_params.referrer.policy,
1975 // TODO(davidben): This is only used for prerenders. Replace 1974 // TODO(davidben): This is only used for prerenders. Replace
1976 // is_showing with something for that. Or maybe it just comes from the 1975 // is_showing with something for that. Or maybe it just comes from the
1977 // same mechanism as the cookie one. 1976 // same mechanism as the cookie one.
1978 blink::WebPageVisibilityStateVisible, 1977 blink::WebPageVisibilityStateVisible,
1979 resource_context, 1978 resource_context,
1980 base::WeakPtr<ResourceMessageFilter>(), // filter 1979 base::WeakPtr<ResourceMessageFilter>(), // filter
1981 true); 1980 true);
1982 // Request takes ownership. 1981 // Request takes ownership.
1983 extra_info->AssociateWithRequest(new_request.get()); 1982 extra_info->AssociateWithRequest(new_request.get());
1984 1983
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 2368
2370 // Add a flag to selectively bypass the data reduction proxy if the resource 2369 // Add a flag to selectively bypass the data reduction proxy if the resource
2371 // type is not an image. 2370 // type is not an image.
2372 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2371 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2373 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2372 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2374 2373
2375 return load_flags; 2374 return load_flags;
2376 } 2375 }
2377 2376
2378 } // namespace content 2377 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698