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

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

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 2 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 16 matching lines...) Expand all
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "content/browser/appcache/appcache_interceptor.h" 28 #include "content/browser/appcache/appcache_interceptor.h"
29 #include "content/browser/appcache/chrome_appcache_service.h" 29 #include "content/browser/appcache/chrome_appcache_service.h"
30 #include "content/browser/bad_message.h" 30 #include "content/browser/bad_message.h"
31 #include "content/browser/cert_store_impl.h" 31 #include "content/browser/cert_store_impl.h"
32 #include "content/browser/child_process_security_policy_impl.h" 32 #include "content/browser/child_process_security_policy_impl.h"
33 #include "content/browser/download/download_resource_handler.h" 33 #include "content/browser/download/download_resource_handler.h"
34 #include "content/browser/download/save_file_manager.h" 34 #include "content/browser/download/save_file_manager.h"
35 #include "content/browser/download/save_file_resource_handler.h" 35 #include "content/browser/download/save_file_resource_handler.h"
36 #include "content/browser/fileapi/chrome_blob_storage_context.h" 36 #include "content/browser/fileapi/chrome_blob_storage_context.h"
37 #include "content/browser/frame_host/navigation_request.h"
37 #include "content/browser/frame_host/navigation_request_info.h" 38 #include "content/browser/frame_host/navigation_request_info.h"
38 #include "content/browser/frame_host/navigator.h" 39 #include "content/browser/frame_host/navigator.h"
39 #include "content/browser/loader/async_resource_handler.h" 40 #include "content/browser/loader/async_resource_handler.h"
40 #include "content/browser/loader/cross_site_resource_handler.h" 41 #include "content/browser/loader/cross_site_resource_handler.h"
41 #include "content/browser/loader/detachable_resource_handler.h" 42 #include "content/browser/loader/detachable_resource_handler.h"
42 #include "content/browser/loader/mime_type_resource_handler.h" 43 #include "content/browser/loader/mime_type_resource_handler.h"
43 #include "content/browser/loader/navigation_resource_handler.h" 44 #include "content/browser/loader/navigation_resource_handler.h"
44 #include "content/browser/loader/navigation_resource_throttle.h" 45 #include "content/browser/loader/navigation_resource_throttle.h"
45 #include "content/browser/loader/navigation_url_loader_impl_core.h" 46 #include "content/browser/loader/navigation_url_loader_impl_core.h"
46 #include "content/browser/loader/power_save_block_resource_throttle.h" 47 #include "content/browser/loader/power_save_block_resource_throttle.h"
47 #include "content/browser/loader/redirect_to_file_resource_handler.h" 48 #include "content/browser/loader/redirect_to_file_resource_handler.h"
48 #include "content/browser/loader/resource_message_filter.h" 49 #include "content/browser/loader/resource_message_filter.h"
49 #include "content/browser/loader/resource_request_info_impl.h" 50 #include "content/browser/loader/resource_request_info_impl.h"
50 #include "content/browser/loader/stream_resource_handler.h" 51 #include "content/browser/loader/stream_resource_handler.h"
51 #include "content/browser/loader/sync_resource_handler.h" 52 #include "content/browser/loader/sync_resource_handler.h"
52 #include "content/browser/loader/throttling_resource_handler.h" 53 #include "content/browser/loader/throttling_resource_handler.h"
53 #include "content/browser/loader/upload_data_stream_builder.h" 54 #include "content/browser/loader/upload_data_stream_builder.h"
54 #include "content/browser/renderer_host/render_view_host_delegate.h" 55 #include "content/browser/renderer_host/render_view_host_delegate.h"
55 #include "content/browser/renderer_host/render_view_host_impl.h" 56 #include "content/browser/renderer_host/render_view_host_impl.h"
56 #include "content/browser/resource_context_impl.h" 57 #include "content/browser/resource_context_impl.h"
58 #include "content/browser/service_worker/service_worker_provider_host.h"
57 #include "content/browser/service_worker/service_worker_request_handler.h" 59 #include "content/browser/service_worker/service_worker_request_handler.h"
58 #include "content/browser/streams/stream.h" 60 #include "content/browser/streams/stream.h"
59 #include "content/browser/streams/stream_context.h" 61 #include "content/browser/streams/stream_context.h"
60 #include "content/browser/streams/stream_registry.h" 62 #include "content/browser/streams/stream_registry.h"
61 #include "content/browser/web_contents/web_contents_impl.h" 63 #include "content/browser/web_contents/web_contents_impl.h"
62 #include "content/common/appcache_interfaces.h" 64 #include "content/common/appcache_interfaces.h"
63 #include "content/common/navigation_params.h" 65 #include "content/common/navigation_params.h"
64 #include "content/common/resource_messages.h" 66 #include "content/common/resource_messages.h"
65 #include "content/common/site_isolation_policy.h" 67 #include "content/common/site_isolation_policy.h"
66 #include "content/common/ssl_status_serialization.h" 68 #include "content/common/ssl_status_serialization.h"
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 1952
1951 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1953 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1952 net::URLRequest* request) { 1954 net::URLRequest* request) {
1953 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1955 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1954 IncrementOutstandingRequestsCount(-1, info); 1956 IncrementOutstandingRequestsCount(-1, info);
1955 } 1957 }
1956 1958
1957 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1959 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1958 ResourceContext* resource_context, 1960 ResourceContext* resource_context,
1959 const NavigationRequestInfo& info, 1961 const NavigationRequestInfo& info,
1960 NavigationURLLoaderImplCore* loader) { 1962 NavigationURLLoaderImplCore* loader,
1963 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) {
1961 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1964 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1962 // browser-side navigations project. 1965 // browser-side navigations project.
1963 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1966 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1964 switches::kEnableBrowserSideNavigation)); 1967 switches::kEnableBrowserSideNavigation));
1965 1968
1966 ResourceType resource_type = info.is_main_frame ? 1969 ResourceType resource_type = info.is_main_frame ?
1967 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1970 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1968 1971
1969 if (is_shutdown_ || 1972 if (is_shutdown_ ||
1970 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1973 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 } 2018 }
2016 2019
2017 SetReferrerForRequest(new_request.get(), info.common_params.referrer); 2020 SetReferrerForRequest(new_request.get(), info.common_params.referrer);
2018 2021
2019 net::HttpRequestHeaders headers; 2022 net::HttpRequestHeaders headers;
2020 headers.AddHeadersFromString(info.begin_params.headers); 2023 headers.AddHeadersFromString(info.begin_params.headers);
2021 new_request->SetExtraRequestHeaders(headers); 2024 new_request->SetExtraRequestHeaders(headers);
2022 2025
2023 new_request->SetLoadFlags(load_flags); 2026 new_request->SetLoadFlags(load_flags);
2024 2027
2028 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2029 GetChromeBlobStorageContextForResourceContext(resource_context));
2030
2025 // Resolve elements from request_body and prepare upload data. 2031 // Resolve elements from request_body and prepare upload data.
2026 if (info.request_body.get()) { 2032 if (info.request_body.get()) {
2027 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2028 GetChromeBlobStorageContextForResourceContext(resource_context));
2029 AttachRequestBodyBlobDataHandles( 2033 AttachRequestBodyBlobDataHandles(
2030 info.request_body.get(), 2034 info.request_body.get(),
2031 blob_context); 2035 blob_context);
2032 // TODO(davidben): The FileSystemContext is null here. In the case where 2036 // TODO(davidben): The FileSystemContext is null here. In the case where
2033 // another renderer requested this navigation, this should be the same 2037 // another renderer requested this navigation, this should be the same
2034 // FileSystemContext passed into ShouldServiceRequest. 2038 // FileSystemContext passed into ShouldServiceRequest.
2035 new_request->set_upload(UploadDataStreamBuilder::Build( 2039 new_request->set_upload(UploadDataStreamBuilder::Build(
2036 info.request_body.get(), 2040 info.request_body.get(),
2037 blob_context, 2041 blob_context,
2038 nullptr, // file_system_context 2042 nullptr, // file_system_context
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 resource_context, 2081 resource_context,
2078 base::WeakPtr<ResourceMessageFilter>(), // filter 2082 base::WeakPtr<ResourceMessageFilter>(), // filter
2079 false, // request_data.report_raw_headers 2083 false, // request_data.report_raw_headers
2080 true); 2084 true);
2081 // Request takes ownership. 2085 // Request takes ownership.
2082 extra_info->AssociateWithRequest(new_request.get()); 2086 extra_info->AssociateWithRequest(new_request.get());
2083 2087
2084 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2088 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2085 // Hang on to a reference to ensure the blob is not released prior 2089 // Hang on to a reference to ensure the blob is not released prior
2086 // to the job being started. 2090 // to the job being started.
2087 ChromeBlobStorageContext* blob_context = 2091 ChromeBlobStorageContext* blob_context =
nasko 2015/10/02 22:09:45 This variable now will shadow the one on line 2028
Fabrice (no longer in Chrome) 2015/10/06 17:21:38 Done.
2088 GetChromeBlobStorageContextForResourceContext(resource_context); 2092 GetChromeBlobStorageContextForResourceContext(resource_context);
2089 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2093 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2090 new_request.get(), 2094 new_request.get(),
2091 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); 2095 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
2092 } 2096 }
2093 2097
2094 // TODO(davidben): Attach ServiceWorkerRequestHandler. 2098 RequestContextFrameType frame_type =
2095 // TODO(michaeln): Help out with this and that. 2099 info.is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL
2100 : REQUEST_CONTEXT_FRAME_TYPE_NESTED;
2101 ServiceWorkerRequestHandler::InitializeForNavigation(
2102 new_request.get(), service_worker_context.get(), blob_context,
2103 info.service_worker_provider_id, info.begin_params.skip_service_worker,
2104 resource_type, info.begin_params.request_context_type, frame_type,
2105 info.request_body);
2106
2096 // TODO(davidben): Attach AppCacheInterceptor. 2107 // TODO(davidben): Attach AppCacheInterceptor.
2097 2108
2098 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2109 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2099 new_request.get(), loader)); 2110 new_request.get(), loader));
2100 2111
2101 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2112 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2102 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2113 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2103 // currently it's a no-op. 2114 // currently it's a no-op.
2104 handler = AddStandardHandlers(new_request.get(), resource_type, 2115 handler = AddStandardHandlers(new_request.get(), resource_type,
2105 resource_context, 2116 resource_context,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 load_flags |= net::LOAD_PREFETCH; 2437 load_flags |= net::LOAD_PREFETCH;
2427 } 2438 }
2428 2439
2429 if (is_sync_load) 2440 if (is_sync_load)
2430 load_flags |= net::LOAD_IGNORE_LIMITS; 2441 load_flags |= net::LOAD_IGNORE_LIMITS;
2431 2442
2432 return load_flags; 2443 return load_flags;
2433 } 2444 }
2434 2445
2435 } // namespace content 2446 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698