Chromium Code Reviews

Issue 472103003: Service Worker: Handle same-scope, new script registration (Closed)

Created:
6 years, 4 months ago by falken
Modified:
6 years, 3 months ago
Reviewers:
michaeln, nhiroki
CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, tzik, serviceworker-reviews, jam, kinuko+serviceworker, nhiroki, darin-cc_chromium.org, horo+watch_chromium.org
Project:
chromium
Visibility:
Public.

Description

Service Worker: Handle same-scope, new script registration Before this patch, register() would delete an existing registration at the scope if the script URL didn't match, and register a new one. This overwriting creates a scenario where old tabs have a different controller than new tabs, which the Service Worker spec avoids. This patch implements the spec steps for same-scope, new script register(). That means: - If the existing registration is uninstalling, wait for that to complete before doing anything. - Create a new worker which becomes the installing worker of the existing registration. BUG=398355 TEST=https://codereview.chromium.org/480943002/ Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=291078

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Total comments: 6

Patch Set 7 : review comments #

Patch Set 8 : patch for landing #

Total comments: 2
Unified diffs Side-by-side diffs Stats (+149 lines, -70 lines)
M content/browser/service_worker/service_worker_context_unittest.cc View 2 chunks +3 lines, -5 lines 0 comments
M content/browser/service_worker/service_worker_handle.cc View 1 chunk +1 line, -1 line 0 comments
M content/browser/service_worker/service_worker_job_unittest.cc View 2 chunks +3 lines, -5 lines 0 comments
M content/browser/service_worker/service_worker_provider_host.h View 1 chunk +1 line, -1 line 0 comments
M content/browser/service_worker/service_worker_register_job.h View 5 chunks +25 lines, -11 lines 0 comments
M content/browser/service_worker/service_worker_register_job.cc View 5 chunks +75 lines, -25 lines 2 comments
M content/browser/service_worker/service_worker_registration.h View 5 chunks +22 lines, -15 lines 0 comments
M content/browser/service_worker/service_worker_registration.cc View 4 chunks +19 lines, -7 lines 0 comments

Messages

Total messages: 12 (0 generated)
falken
PTAL
6 years, 4 months ago (2014-08-20 09:35:36 UTC) #1
nhiroki
LGTM with nits! https://codereview.chromium.org/472103003/diff/100001/content/browser/service_worker/service_worker_register_job.cc File content/browser/service_worker/service_worker_register_job.cc (right): https://codereview.chromium.org/472103003/diff/100001/content/browser/service_worker/service_worker_register_job.cc#newcode224 content/browser/service_worker/service_worker_register_job.cc:224: Just an idea: To explicitly ensure ...
6 years, 4 months ago (2014-08-21 01:57:17 UTC) #2
falken
Thanks for reviewing. https://codereview.chromium.org/472103003/diff/100001/content/browser/service_worker/service_worker_register_job.cc File content/browser/service_worker/service_worker_register_job.cc (right): https://codereview.chromium.org/472103003/diff/100001/content/browser/service_worker/service_worker_register_job.cc#newcode224 content/browser/service_worker/service_worker_register_job.cc:224: On 2014/08/21 01:57:17, nhiroki wrote: > ...
6 years, 4 months ago (2014-08-21 02:40:39 UTC) #3
falken
The CQ bit was checked by falken@chromium.org
6 years, 4 months ago (2014-08-21 14:25:33 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/falken@chromium.org/472103003/140001
6 years, 4 months ago (2014-08-21 14:26:55 UTC) #5
commit-bot: I haz the power
Committed patchset #8 (140001) as 291078
6 years, 4 months ago (2014-08-21 15:27:29 UTC) #6
dglazkov
On 2014/08/21 at 15:27:29, commit-bot wrote: > Committed patchset #8 (140001) as 291078 I think ...
6 years, 4 months ago (2014-08-21 16:18:10 UTC) #7
falken
On 2014/08/21 16:18:10, dglazkov wrote: > On 2014/08/21 at 15:27:29, commit-bot wrote: > > Committed ...
6 years, 4 months ago (2014-08-21 16:26:23 UTC) #8
falken
A revert of this CL (patchset #8) has been created in https://codereview.chromium.org/484783003/ by falken@chromium.org. The ...
6 years, 4 months ago (2014-08-21 16:27:39 UTC) #9
dglazkov
A revert of this CL (patchset #8) has been created in https://codereview.chromium.org/487393003/ by dglazkov@chromium.org. The ...
6 years, 4 months ago (2014-08-21 16:30:42 UTC) #10
michaeln
https://codereview.chromium.org/472103003/diff/140001/content/browser/service_worker/service_worker_register_job.cc File content/browser/service_worker/service_worker_register_job.cc (right): https://codereview.chromium.org/472103003/diff/140001/content/browser/service_worker/service_worker_register_job.cc#newcode223 content/browser/service_worker/service_worker_register_job.cc:223: existing_registration->set_script_url(script_url_); This can put the object in a strange ...
6 years, 4 months ago (2014-08-21 23:52:44 UTC) #11
falken
6 years, 4 months ago (2014-08-22 11:08:00 UTC) #12
https://codereview.chromium.org/472103003/diff/140001/content/browser/service...
File content/browser/service_worker/service_worker_register_job.cc (right):

https://codereview.chromium.org/472103003/diff/140001/content/browser/service...
content/browser/service_worker/service_worker_register_job.cc:223:
existing_registration->set_script_url(script_url_);
Thanks for taking a look!

On 2014/08/21 23:52:44, michaeln wrote:
> This can put the object in a strange state where .active, .installing, and
> .waiting can have different script urls.

Yep, I'm trying to support .active, .installing, .waiting with different
script URLs.

> Up till now scripturl has been an
> invariant, is anything depending on that invariant> If this job fails (suppose
> newScriptUrl is 404s), does this class get left in an incoherent state?
> 
> reg.url == newScript (in memory but not on disk)
> reg.activeVersion.url == oldScript
> there is no waiting or installing version and there is no job running
> 
> Maybe reg shouldn't have a scripturl datamember and instead the accessor
should
> reflects the url of its newest version?

That's a very good idea, and I think it's what the spec intended. I commented
on GitHub for that 404 case.

I created a patch to remove script URL from SWRegistration
outright, it should land before attempting this patch:
https://codereview.chromium.org/501453002/

Powered by Google App Engine