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

Unified Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 2446553002: Support Service Worker NavigationPreload with PlzNavigate. (Closed)
Patch Set: remove unnecessary comment Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_provider_host.cc
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc
index c36829aa959e0490b0c4f40d31f5a873e09697af..7bbc833d7b7a9fe1cf1a1387ddce46eb5a891223 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -52,17 +52,20 @@ ServiceWorkerProviderHost::OneShotGetReadyCallback::~OneShotGetReadyCallback() {
std::unique_ptr<ServiceWorkerProviderHost>
ServiceWorkerProviderHost::PreCreateNavigationHost(
base::WeakPtr<ServiceWorkerContextCore> context,
+ const MojoURLLoaderFactoryGetter& url_loader_factory_getter,
bool are_ancestors_secure) {
CHECK(IsBrowserSideNavigationEnabled());
// Generate a new browser-assigned id for the host.
int provider_id = g_next_navigation_provider_id--;
- return std::unique_ptr<ServiceWorkerProviderHost>(
- new ServiceWorkerProviderHost(
+ std::unique_ptr<ServiceWorkerProviderHost> host(
+ base::MakeUnique<ServiceWorkerProviderHost>(
ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE, provider_id,
SERVICE_WORKER_PROVIDER_FOR_WINDOW,
are_ancestors_secure ? FrameSecurityLevel::SECURE
: FrameSecurityLevel::INSECURE,
context, nullptr));
+ host->url_loader_factory_getter_ = url_loader_factory_getter;
+ return host;
}
ServiceWorkerProviderHost::ServiceWorkerProviderHost(
@@ -82,7 +85,10 @@ ServiceWorkerProviderHost::ServiceWorkerProviderHost(
parent_frame_security_level_(parent_frame_security_level),
context_(context),
dispatcher_host_(dispatcher_host),
- allow_association_(true) {
+ allow_association_(true),
+ url_loader_factory_getter_(
+ dispatcher_host_ ? dispatcher_host_->url_loader_factory_getter()
+ : MojoURLLoaderFactoryGetter()) {
DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_);
// PlzNavigate
@@ -341,14 +347,12 @@ ServiceWorkerProviderHost::CreateRequestHandler(
}
if (ServiceWorkerUtils::IsMainResourceType(resource_type) ||
controlling_version()) {
- // |dispatcher_host_| may be null in some unittests.
return std::unique_ptr<ServiceWorkerRequestHandler>(
new ServiceWorkerControlleeRequestHandler(
context_, AsWeakPtr(), blob_storage_context, request_mode,
credentials_mode, redirect_mode, resource_type,
request_context_type, frame_type, body,
- dispatcher_host_ ? dispatcher_host_->url_loader_factory_getter()
- : MojoURLLoaderFactoryGetter()));
+ url_loader_factory_getter_));
}
return std::unique_ptr<ServiceWorkerRequestHandler>();
}
@@ -458,6 +462,7 @@ void ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() {
provider_id_ = kInvalidServiceWorkerProviderId;
provider_type_ = SERVICE_WORKER_PROVIDER_UNKNOWN;
dispatcher_host_ = nullptr;
+ url_loader_factory_getter_ = MojoURLLoaderFactoryGetter();
}
void ServiceWorkerProviderHost::CompleteCrossSiteTransfer(
@@ -661,9 +666,11 @@ void ServiceWorkerProviderHost::FinalizeInitialization(
int process_id,
int frame_routing_id,
ServiceWorkerDispatcherHost* dispatcher_host) {
+ DCHECK(dispatcher_host);
render_process_id_ = process_id;
route_id_ = frame_routing_id;
dispatcher_host_ = dispatcher_host;
+ url_loader_factory_getter_ = dispatcher_host_->url_loader_factory_getter();
for (const GURL& pattern : associated_patterns_)
IncreaseProcessReference(pattern);
@@ -673,7 +680,7 @@ void ServiceWorkerProviderHost::FinalizeInitialization(
if (associated_registration_.get()) {
SendAssociateRegistrationMessage();
- if (dispatcher_host_ && associated_registration_->active_version()) {
+ if (associated_registration_->active_version()) {
Send(new ServiceWorkerMsg_SetControllerServiceWorker(
render_thread_id_, provider_id(),
GetOrCreateServiceWorkerHandle(

Powered by Google App Engine
This is Rietveld 408576698