Commit 43559dbd authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Clean up SendSetController.

This can be simplified since PlzNavigate shipped. Follow-up to
r528894.

Change-Id: Ib8044a689882456c519fc522d96846e6572f7abb
Reviewed-on: https://chromium-review.googlesource.com/890678Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532326}
parent 6ebde5ea
...@@ -350,7 +350,7 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute( ...@@ -350,7 +350,7 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute(
// SetController message should be sent only for clients. // SetController message should be sent only for clients.
DCHECK(IsProviderForClient()); DCHECK(IsProviderForClient());
SendSetControllerServiceWorker(version, notify_controllerchange); SendSetControllerServiceWorker(notify_controllerchange);
} }
bool ServiceWorkerProviderHost::IsProviderForClient() const { bool ServiceWorkerProviderHost::IsProviderForClient() const {
...@@ -626,8 +626,7 @@ void ServiceWorkerProviderHost::CompleteNavigationInitialized( ...@@ -626,8 +626,7 @@ void ServiceWorkerProviderHost::CompleteNavigationInitialized(
// commit, but we still need this for S13nServiceWorker case for setting the // commit, but we still need this for S13nServiceWorker case for setting the
// use counter correctly. // use counter correctly.
// TODO(kinuko): Stop doing this in S13nServiceWorker case. // TODO(kinuko): Stop doing this in S13nServiceWorker case.
SendSetControllerServiceWorker(controller_.get(), SendSetControllerServiceWorker(false /* notify_controllerchange */);
false /* notify_controllerchange */);
} }
mojom::ServiceWorkerProviderInfoForStartWorkerPtr mojom::ServiceWorkerProviderInfoForStartWorkerPtr
...@@ -774,32 +773,35 @@ void ServiceWorkerProviderHost::Send(IPC::Message* message) const { ...@@ -774,32 +773,35 @@ void ServiceWorkerProviderHost::Send(IPC::Message* message) const {
} }
void ServiceWorkerProviderHost::SendSetControllerServiceWorker( void ServiceWorkerProviderHost::SendSetControllerServiceWorker(
ServiceWorkerVersion* version,
bool notify_controllerchange) { bool notify_controllerchange) {
if (!dispatcher_host_) if (!dispatcher_host_)
return; return;
if (version) { if (!controller_) {
DCHECK(associated_registration_); container_->SetController(mojom::ControllerServiceWorkerInfo::New(),
DCHECK_EQ(associated_registration_->active_version(), version); {} /* used_features */, notify_controllerchange);
DCHECK_EQ(controller_.get(), version); return;
} }
std::vector<blink::mojom::WebFeature> used_features; DCHECK(associated_registration_);
if (version) { DCHECK_EQ(associated_registration_->active_version(), controller_.get());
for (const uint32_t feature : version->used_features()) {
DCHECK_LT(feature, static_cast<uint32_t>(
blink::mojom::WebFeature::kNumberOfFeatures));
used_features.push_back(static_cast<blink::mojom::WebFeature>(feature));
}
}
auto controller_info = mojom::ControllerServiceWorkerInfo::New(); auto controller_info = mojom::ControllerServiceWorkerInfo::New();
controller_info->object_info = GetOrCreateServiceWorkerHandle(version); // Set the info for the JavaScript ServiceWorkerContainer#controller object.
controller_info->object_info =
GetOrCreateServiceWorkerHandle(controller_.get());
// Populate used features for UseCounter purposes.
std::vector<blink::mojom::WebFeature> used_features;
for (const uint32_t feature : controller_->used_features()) {
DCHECK_LT(feature, static_cast<uint32_t>(
blink::mojom::WebFeature::kNumberOfFeatures));
used_features.push_back(static_cast<blink::mojom::WebFeature>(feature));
}
// S13nServiceWorker: Send the controller ptr too so that controller changes/ // S13nServiceWorker: Pass an endpoint for the client to talk to this
// lost are propagated with the new controller ptr. // controller.
if (version && ServiceWorkerUtils::IsServicificationEnabled()) if (ServiceWorkerUtils::IsServicificationEnabled())
controller_info->endpoint = GetControllerServiceWorkerPtr().PassInterface(); controller_info->endpoint = GetControllerServiceWorkerPtr().PassInterface();
container_->SetController(std::move(controller_info), used_features, container_->SetController(std::move(controller_info), used_features,
......
...@@ -421,15 +421,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost ...@@ -421,15 +421,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
// Sends information about the controller to the providers of the service // Sends information about the controller to the providers of the service
// worker clients in the renderer. If |notify_controllerchange| is true, // worker clients in the renderer. If |notify_controllerchange| is true,
// instructs the renderer to dispatch a 'controllerchange' event. If // instructs the renderer to dispatch a 'controllerchange' event.
// |version| is non-null, it must be the same as |controller_|. |version| can void SendSetControllerServiceWorker(bool notify_controllerchange);
// be null while |controller_| is non-null in the strange case of cross-site
// transfer, which will be removed when the non-PlzNavigate code path is
// removed.
// TODO(falken): As non-PlzNavigate and cross-site transfer were removed, see
// if this can be simplified.
void SendSetControllerServiceWorker(ServiceWorkerVersion* version,
bool notify_controllerchange);
// Implements mojom::ServiceWorkerContainerHost. // Implements mojom::ServiceWorkerContainerHost.
void Register(const GURL& script_url, void Register(const GURL& script_url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment