Commit 3b580697 authored by Leon Han's avatar Leon Han Committed by Commit Bot

[ServiceWorker] Propagate UseCounter to controllee document upon execution ready

For a controllee document, the initial set of used features of its
controller service worker are sent to the renderer process as part of
ControllerServiceWorkerInfo via navigation commit IPC, however, after
that the controller service worker may have used some other new
features, which are also needed to be propagated to the document in the
renderer process for setting UseCounter correctly.

Previously, the provider host holds off doing this until it received
the ServiceWorkerContainerHost::OnProviderCreated() Mojo call.

This CL postpones doing that further until the
ServiceWorkerContainerHost::OnExecutionReady() Mojo call came, which
should have no bad effect, but help reduce the burden of
ServiceWorkerProviderHost::OnProviderCreated() to make it easier for us
to remove the ServiceWorkerContainerHost::OnProviderCreated() Mojo call
completely later.

BUG=931092

Change-Id: Iaf8505576064bad76335c07e806eba35aa9c5e05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1531824Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#644723}
parent 92ffac89
......@@ -860,10 +860,10 @@ void ServiceWorkerProviderHost::SendSetControllerServiceWorker(
bool ServiceWorkerProviderHost::IsControllerDecided() const {
DCHECK(IsProviderForClient());
if (is_response_committed())
if (is_execution_ready())
return true;
// TODO(falken): This function just becomes |is_response_committed()|
// TODO(falken): This function just becomes |is_execution_ready()|
// when NetworkService is enabled, so remove/simplify it when
// non-NetworkService code is removed.
......@@ -1203,17 +1203,6 @@ void ServiceWorkerProviderHost::OnProviderCreated() {
DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_);
TransitionToClientPhase(ClientPhase::kResponseCommitted);
// Now that there is a connection with the renderer-side provider, initialize
// the handle for ServiceWorkerContainer#controller, and send the controller
// info to the renderer if needed.
if (!controller_)
return;
// The controller is already sent in navigation commit, but we still need this
// for setting the use counter correctly.
// TODO(kinuko): Stop doing this.
SendSetControllerServiceWorker(false /* notify_controllerchange */);
}
void ServiceWorkerProviderHost::OnExecutionReady() {
......@@ -1227,6 +1216,15 @@ void ServiceWorkerProviderHost::OnExecutionReady() {
return;
}
// The controller was sent on navigation commit but we must send it again here
// because 1) the controller might have changed since navigation commit due to
// skipWaiting(), and 2) the UseCounter might have changed since navigation
// commit, in such cases the updated information was prevented being sent due
// to false IsControllerDecided().
// TODO(leonhsl): Create some layout tests covering the above case 1), in
// which case we may also need to set |notify_controllerchange| correctly.
SendSetControllerServiceWorker(false /* notify_controllerchange */);
SetExecutionReady();
}
......
......@@ -481,6 +481,7 @@ TEST_F(ServiceWorkerProviderHostTest, Controller) {
FinishNavigation(host.get());
host->SetControllerRegistration(registration1_,
false /* notify_controllerchange */);
remote_endpoints_.back().host_ptr()->get()->OnExecutionReady();
base::RunLoop().RunUntilIdle();
// The page should be controlled since there was an active version at the
......
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