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

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts

Created:
3 years, 9 months ago by yuryu
Modified:
3 years, 4 months ago
Reviewers:
falken, nhiroki
CC:
chromium-reviews, kenjibaheux+watch_chromium.org, tzik, kinuko+watch, jsbell+serviceworker_chromium.org, Yoav Weiss, blink-reviews-html_chromium.org, jam, dglazkov+blink, darin-cc_chromium.org, blink-reviews, falken+watch_chromium.org, android-webview-reviews_chromium.org, blink-worker-reviews_chromium.org, haraken, michaeln, shimazu+serviceworker_chromium.org, gavinp+prerender_chromium.org, serviceworker-reviews, blink-reviews-api_chromium.org, kinuko+serviceworker, mac-reviews_chromium.org, horo+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

updateViaCache is an attribute on ServiceWorkerRegistration that controls whether the browser cache (the HTTP cache) is used when performing an update check. Service workers consist of a main script and possibly imported scripts. The service worker update check involves fetching the current scripts and comparing them to the installed scripts. This intent to ship concerns whether fetching the current scripts uses or bypasses the browser cache. BUG=675540

Patch Set 1 #

Total comments: 15

Patch Set 2 : fix tests #

Total comments: 12

Patch Set 3 : rebase #

Patch Set 4 : wip / fixing tests #

Patch Set 5 : change useCache to updateViaCache #

Total comments: 14

Patch Set 6 : Move API change to another patch and address comments #

Total comments: 10

Patch Set 7 : fix compile error & address more comments #

Patch Set 8 : rebase #

Patch Set 9 : fix another compile error #

Patch Set 10 : fix a database error #

Total comments: 6

Patch Set 11 : address even more comments #

Patch Set 12 : rebase #

Patch Set 13 : fix IPC #

Unified diffs Side-by-side diffs Delta from patch set Stats (+598 lines, -199 lines) Patch
M android_webview/tools/system_webview_shell/test/data/webexposed/global-interface-listing-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -0 lines 0 comments Download
M chrome/browser/DEPS View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/chrome_service_worker_browsertest.cc View 1 2 3 4 5 6 7 5 chunks +5 lines, -0 lines 0 comments Download
M content/browser/DEPS View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/browsing_data/clear_site_data_throttle_browsertest.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/service_worker/link_header_support.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +24 lines, -1 line 0 comments Download
M content/browser/service_worker/link_header_support_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 7 chunks +90 lines, -2 lines 0 comments Download
M content/browser/service_worker/service_worker_browsertest.cc View 1 2 3 4 5 6 7 12 chunks +13 lines, -3 lines 0 comments Download
M content/browser/service_worker/service_worker_context_request_handler.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +15 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_context_request_handler_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +46 lines, -7 lines 0 comments Download
M content/browser/service_worker/service_worker_context_unittest.cc View 1 2 3 4 5 6 7 1 chunk +3 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_context_wrapper.h View 1 2 3 4 5 6 7 1 chunk +5 lines, -3 lines 0 comments Download
M content/browser/service_worker/service_worker_context_wrapper.cc View 1 2 3 4 5 6 7 2 chunks +6 lines, -8 lines 0 comments Download
M content/browser/service_worker/service_worker_database.h View 1 2 3 4 5 6 3 chunks +3 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_database.cc View 1 2 3 4 5 6 7 8 9 3 chunks +18 lines, -2 lines 0 comments Download
M content/browser/service_worker/service_worker_database.proto View 1 2 3 4 5 6 7 8 9 10 2 chunks +9 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_database_unittest.cc View 1 2 3 4 4 chunks +4 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_info.h View 1 2 3 4 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_info.cc View 1 2 3 4 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_job_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 6 chunks +72 lines, -4 lines 0 comments Download
M content/browser/service_worker/service_worker_register_job.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_register_job.cc View 1 2 3 4 5 6 7 8 9 10 11 12 6 chunks +15 lines, -6 lines 0 comments Download
M content/browser/service_worker/service_worker_registration.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +8 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_registration.cc View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_registration_handle.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +2 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_storage.cc View 1 2 3 4 5 6 7 3 chunks +4 lines, -2 lines 0 comments Download
M content/browser/service_worker/service_worker_write_to_cache_job.h View 1 1 chunk +3 lines, -1 line 0 comments Download
M content/child/service_worker/service_worker_dispatcher.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M content/child/service_worker/service_worker_dispatcher.cc View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +8 lines, -2 lines 0 comments Download
M content/child/service_worker/service_worker_registration_handle_reference.h View 1 2 3 4 5 1 chunk +3 lines, -0 lines 0 comments Download
M content/child/service_worker/web_service_worker_provider_impl.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M content/child/service_worker/web_service_worker_provider_impl.cc View 1 2 3 4 5 1 chunk +3 lines, -1 line 0 comments Download
M content/child/service_worker/web_service_worker_registration_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +4 lines, -0 lines 0 comments Download
M content/child/service_worker/web_service_worker_registration_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +10 lines, -0 lines 0 comments Download
M content/common/DEPS View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M content/common/service_worker/service_worker_messages.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -0 lines 0 comments Download
M content/common/service_worker/service_worker_types.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +6 lines, -2 lines 0 comments Download
M content/common/service_worker/service_worker_types.cc View 1 2 3 4 5 6 7 1 chunk +12 lines, -3 lines 0 comments Download
M content/public/browser/service_worker_context.h View 1 2 3 4 5 6 7 3 chunks +13 lines, -6 lines 0 comments Download
M content/public/test/mock_service_worker_context.h View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/interfaces-sw.https-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +2 lines, -2 lines 0 comments Download
D third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/interfaces-window.https-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +0 lines, -101 lines 0 comments Download
D third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/registration-updateviacache.https-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +0 lines, -31 lines 0 comments Download
M third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/interfaces-idls.js View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/platform/mac/virtual/stable/webexposed/global-interface-listing-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/platform/win/virtual/stable/webexposed/global-interface-listing-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/virtual/service-worker-navigation-preload/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces-expected.txt View 1 2 3 4 4 chunks +6 lines, -3 lines 0 comments Download
M third_party/WebKit/LayoutTests/virtual/service-worker-navigation-preload/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/virtual/stable/webexposed/element-instance-property-listing-expected.txt View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLAttributeNames.json5 View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLLinkElement.h View 1 2 3 4 4 chunks +7 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLLinkElement.cpp View 1 2 3 4 5 6 7 2 chunks +16 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLLinkElement.idl View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/RegistrationOptions.idl View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp View 1 2 3 4 5 6 7 8 9 10 4 chunks +21 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 6 chunks +39 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerLinkResource.cpp View 1 2 3 4 3 chunks +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp View 1 2 3 4 5 6 1 chunk +15 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.idl View 1 2 3 4 5 2 chunks +7 lines, -0 lines 0 comments Download
M third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h View 1 2 3 4 5 6 7 2 chunks +2 lines, -0 lines 0 comments Download
M third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h View 1 2 3 4 2 chunks +6 lines, -1 line 0 comments Download
A third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerUpdateViaCache.h View 1 2 3 4 1 chunk +20 lines, -0 lines 0 comments Download

Messages

Total messages: 63 (43 generated)
nhiroki
Thank you for working on this. Added unsolicited comments :) > Should I split it ...
3 years, 9 months ago (2017-03-24 00:33:42 UTC) #6
nhiroki
+falken. I know this is still WIP and not ready for formal reviews, but early ...
3 years, 9 months ago (2017-03-24 00:46:43 UTC) #8
falken
This looks reasonable to me and I agree with nhiroki's comments. https://codereview.chromium.org/2771823002/diff/1/content/common/service_worker/service_worker_types.h File content/common/service_worker/service_worker_types.h (right): ...
3 years, 9 months ago (2017-03-24 04:06:20 UTC) #9
yuryu
https://codereview.chromium.org/2771823002/diff/1/content/public/browser/service_worker_context.h File content/public/browser/service_worker_context.h (right): https://codereview.chromium.org/2771823002/diff/1/content/public/browser/service_worker_context.h#newcode71 content/public/browser/service_worker_context.h:71: bool use_cache, On 2017/03/24 04:06:19, falken wrote: > Do ...
3 years, 9 months ago (2017-03-24 04:45:55 UTC) #10
falken
https://codereview.chromium.org/2771823002/diff/1/content/public/browser/service_worker_context.h File content/public/browser/service_worker_context.h (right): https://codereview.chromium.org/2771823002/diff/1/content/public/browser/service_worker_context.h#newcode71 content/public/browser/service_worker_context.h:71: bool use_cache, On 2017/03/24 04:45:55, yuryu wrote: > On ...
3 years, 9 months ago (2017-03-27 06:15:37 UTC) #11
yuryu
https://codereview.chromium.org/2771823002/diff/1/content/browser/service_worker/service_worker_context_core.h File content/browser/service_worker/service_worker_context_core.h (right): https://codereview.chromium.org/2771823002/diff/1/content/browser/service_worker/service_worker_context_core.h#newcode199 content/browser/service_worker/service_worker_context_core.h:199: bool use_cache, On 2017/03/24 00:33:42, nhiroki wrote: > Enum ...
3 years, 8 months ago (2017-03-28 05:08:56 UTC) #12
nhiroki
Looks good overall. Can you flesh out the CL description? A CL that launches a ...
3 years, 8 months ago (2017-03-28 06:49:52 UTC) #21
yuryu
On 2017/03/28 06:49:52, nhiroki wrote: > Can you flesh out the CL description? A CL ...
3 years, 8 months ago (2017-03-28 07:07:02 UTC) #22
nhiroki
https://codereview.chromium.org/2771823002/diff/20001/content/browser/service_worker/service_worker_registration.h File content/browser/service_worker/service_worker_registration.h (right): https://codereview.chromium.org/2771823002/diff/20001/content/browser/service_worker/service_worker_registration.h#newcode199 content/browser/service_worker/service_worker_registration.h:199: const bool use_cache_; On 2017/03/28 07:07:02, yuryu wrote: > ...
3 years, 8 months ago (2017-03-28 07:21:50 UTC) #23
falken
Heads-up that the spec here is changing: https://github.com/w3c/ServiceWorker/issues/893 I think we should update the patch ...
3 years, 8 months ago (2017-04-05 01:01:08 UTC) #24
yuryu
Thanks for the update. I'll implement it as a boolean behind a flag. The new ...
3 years, 8 months ago (2017-04-05 02:25:24 UTC) #25
yuryu
I've rebased and made changes, so the delta contains unrelated changes... Now I need to ...
3 years, 6 months ago (2017-06-21 12:40:49 UTC) #28
nhiroki
Partially commented. https://codereview.chromium.org/2771823002/diff/80001/android_webview/tools/system_webview_shell/test/data/webexposed/global-interface-listing-expected.txt File android_webview/tools/system_webview_shell/test/data/webexposed/global-interface-listing-expected.txt (right): https://codereview.chromium.org/2771823002/diff/80001/android_webview/tools/system_webview_shell/test/data/webexposed/global-interface-listing-expected.txt#newcode1953 android_webview/tools/system_webview_shell/test/data/webexposed/global-interface-listing-expected.txt:1953: getter useCache s/useCache/updateViaCache/ https://codereview.chromium.org/2771823002/diff/80001/content/browser/service_worker/service_worker_database.h File content/browser/service_worker/service_worker_database.h (right): ...
3 years, 6 months ago (2017-06-21 14:08:35 UTC) #32
nhiroki
https://codereview.chromium.org/2771823002/diff/80001/content/browser/service_worker/link_header_support.cc File content/browser/service_worker/link_header_support.cc (right): https://codereview.chromium.org/2771823002/diff/80001/content/browser/service_worker/link_header_support.cc#newcode36 content/browser/service_worker/link_header_support.cc:36: blink::WebServiceWorkerUpdateViaCache ParseUpdateViaCache( Can you add a link to https://html.spec.whatwg.org/multipage/semantics.html#attr-link-updateviacache ...
3 years, 6 months ago (2017-06-21 15:04:59 UTC) #33
yuryu
https://codereview.chromium.org/2771823002/diff/20001/content/browser/service_worker/link_header_support_unittest.cc File content/browser/service_worker/link_header_support_unittest.cc (right): https://codereview.chromium.org/2771823002/diff/20001/content/browser/service_worker/link_header_support_unittest.cc#newcode115 content/browser/service_worker/link_header_support_unittest.cc:115: false /* use_cache* */, 1L, On 2017/03/28 06:49:51, nhiroki ...
3 years, 5 months ago (2017-07-20 10:15:12 UTC) #34
nhiroki
Partially reviewed. I'll take a closer look later. https://codereview.chromium.org/2771823002/diff/100001/content/browser/service_worker/service_worker_context_request_handler_unittest.cc File content/browser/service_worker/service_worker_context_request_handler_unittest.cc (right): https://codereview.chromium.org/2771823002/diff/100001/content/browser/service_worker/service_worker_context_request_handler_unittest.cc#newcode69 content/browser/service_worker/service_worker_context_request_handler_unittest.cc:69: SetUpServiceWorker(); ...
3 years, 5 months ago (2017-07-21 04:39:46 UTC) #39
yuryu
Still working to fix tests https://codereview.chromium.org/2771823002/diff/80001/content/browser/service_worker/service_worker_database.h File content/browser/service_worker/service_worker_database.h (right): https://codereview.chromium.org/2771823002/diff/80001/content/browser/service_worker/service_worker_database.h#newcode27 content/browser/service_worker/service_worker_database.h:27: #include "url/origin.h" On 2017/06/21 ...
3 years, 4 months ago (2017-08-03 04:20:05 UTC) #42
nhiroki
Looking good. https://codereview.chromium.org/2771823002/diff/180001/content/browser/service_worker/service_worker_context_request_handler.cc File content/browser/service_worker/service_worker_context_request_handler.cc (right): https://codereview.chromium.org/2771823002/diff/180001/content/browser/service_worker/service_worker_context_request_handler.cc#newcode198 content/browser/service_worker/service_worker_context_request_handler.cc:198: blink::WebServiceWorkerUpdateViaCache::kNone; Would it be possible to move ...
3 years, 4 months ago (2017-08-04 09:24:51 UTC) #57
nhiroki
I'll be OOO until Aug 14. Feel free to land this without my stamp after ...
3 years, 4 months ago (2017-08-07 03:55:13 UTC) #58
yuryu
3 years, 4 months ago (2017-08-17 07:36:35 UTC) #59
https://codereview.chromium.org/2771823002/diff/180001/content/browser/servic...
File content/browser/service_worker/service_worker_context_request_handler.cc
(right):

https://codereview.chromium.org/2771823002/diff/180001/content/browser/servic...
content/browser/service_worker/service_worker_context_request_handler.cc:198:
blink::WebServiceWorkerUpdateViaCache::kNone;
On 2017/08/04 09:24:50, nhiroki wrote:
> Would it be possible to move this policy decision to a separate function like
> DetermineIfShouldBypassCache() as follows and add a unit test that covers all
> possible combinations?
> 
> bool DetermineIfShouldBypassCache(
>     bool is_main_script,
>     blink::WebServiceWorkerUpdateViaCache cache_mode) {
>   if (cache_mode == blink::WebServiceWorkerUpdateViaCache::kNone)
>     return true;
>   if (is_main_script && blink::WebServiceWorkerUpdateViaCache::kImported)
>     return true;
>   return false;
> }

I think it makes sense to extract the part to another method as it is fairly
complex already, but I'm not sure if we can/should test functions with internal
linkage.

https://codereview.chromium.org/2771823002/diff/180001/content/browser/servic...
File content/browser/service_worker/service_worker_database.proto (right):

https://codereview.chromium.org/2771823002/diff/180001/content/browser/servic...
content/browser/service_worker/service_worker_database.proto:27: UNKNOWN = 0;
On 2017/08/04 09:24:50, nhiroki wrote:
> I wonder if we don't have to have UNKNOWN type because we shouldn't write a
> registration data to the DB if its cache type is "UNKNOWN".

Done.

https://codereview.chromium.org/2771823002/diff/180001/third_party/WebKit/Sou...
File third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
(right):

https://codereview.chromium.org/2771823002/diff/180001/third_party/WebKit/Sou...
third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp:71:
WebServiceWorkerUpdateViaCache ParseUpdateViaCache(const String& value) {
On 2017/08/04 09:24:50, nhiroki wrote:
> Can you sync this implementation with ParseUpdateViaCache() in
> HTMLLinkElement.cpp?

Done.

Powered by Google App Engine
This is Rietveld 408576698