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

Issue 2658603003: ServiceWorker: Enable UseCounter for ServiceWorkerGlobalScope (Closed)

Created:
3 years, 11 months ago by nhiroki
Modified:
3 years, 10 months ago
Reviewers:
falken, kinuko, haraken, dcheng
CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, mlamouri+watch-content_chromium.org, shimazu+serviceworker_chromium.org, serviceworker-reviews, jam, blink-reviews-api_chromium.org, haraken, dglazkov+blink, kinuko+serviceworker, horo+watch_chromium.org, blink-reviews, darin-cc_chromium.org, kinuko+watch, tzik, falken+watch_chromium.org, blink-worker-reviews_chromium.org, Rick Byers
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

ServiceWorker: Enable UseCounter for ServiceWorkerGlobalScope DesignDoc: https://docs.google.com/document/d/1VyYZnhjBdk-MzCRAcX37TM5-yjwTY40U_J9rWnEAo8c/edit?usp=sharing This CL enables UseCounter for ServiceWorker. This works as follows: - API use on ServiceWorkerGlobalScope is recorded in all documents controlled by the worker. For example, when a service worker controlling 3 documents calls some API, it's recorded in their UseCounter as if they all called the API: [Renderer(Worker)] ---> [Browser] ---> [Renderer(Document1)] (calls API X) ---> [Renderer(Document2)] ---> [Renderer(Document3)] (each document records use of API X; the total count of API X is 3) - When a new document gets controlled by the existing service worker, its counter is synchronized with the current use counts of the worker. [Browser] ---> [Renderer(Document4)] (new doc, but has the same counts with documents1-3; the total count of API X is 4) - By the specification, ServiceWorker can be terminated any time there is no activity and restarted on demand. As long as on-memory representation of service worker in the browser process (i.e., ServiceWorkerVersion) is alive, the counter can outlive worker restart. - The counter is persisted in a service worker storage on installation so that API use during the install event can be counted even when a service worker restarts from on-disk representation. This is necessary for avoiding API use during installation from being underestimated compared to API use after activation (installation happens only one time per service worker version). See the design doc for a discussion of this model. BUG=376039 Review-Url: https://codereview.chromium.org/2658603003 Cr-Commit-Position: refs/heads/master@{#450260} Committed: https://chromium.googlesource.com/chromium/src/+/38e501dfecb476f9666f3833fd2a871a6a03b3c9

Patch Set 1 : ready to review #

Total comments: 27

Patch Set 2 : partially address review comments #

Patch Set 3 : rebase #

Patch Set 4 : tweak unittests #

Total comments: 12

Patch Set 5 : rebase on https://codereview.chromium.org/2680423006/ #

Patch Set 6 : address review comments #

Patch Set 7 : add nullptr check for fixing test failures #

Total comments: 4

Patch Set 8 : int32_t -> uint32_t #

Unified diffs Side-by-side diffs Delta from patch set Stats (+556 lines, -40 lines) Patch
M content/browser/service_worker/service_worker_database.h View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_database.cc View 1 2 3 4 5 6 7 2 chunks +6 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_database.proto View 1 1 chunk +4 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_database_unittest.cc View 4 chunks +4 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_dispatcher_host.h View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_dispatcher_host.cc View 2 chunks +11 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_provider_host.h View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_provider_host.cc View 1 2 3 4 5 6 3 chunks +14 lines, -2 lines 0 comments Download
M content/browser/service_worker/service_worker_storage.cc View 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_storage_unittest.cc View 1 2 3 3 chunks +4 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_version.h View 1 2 3 4 5 2 chunks +11 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_version.cc View 1 2 3 4 1 chunk +7 lines, -0 lines 0 comments Download
M content/child/service_worker/service_worker_dispatcher.h View 2 chunks +4 lines, -1 line 0 comments Download
M content/child/service_worker/service_worker_dispatcher.cc View 1 4 chunks +22 lines, -3 lines 0 comments Download
M content/child/service_worker/service_worker_dispatcher_unittest.cc View 8 chunks +20 lines, -9 lines 0 comments Download
M content/child/service_worker/service_worker_message_filter.h View 2 chunks +3 lines, -1 line 0 comments Download
M content/child/service_worker/service_worker_message_filter.cc View 1 chunk +2 lines, -1 line 0 comments Download
M content/child/service_worker/service_worker_provider_context.h View 1 2 3 4 5 3 chunks +5 lines, -1 line 0 comments Download
M content/child/service_worker/service_worker_provider_context.cc View 1 chunk +3 lines, -1 line 0 comments Download
M content/child/service_worker/web_service_worker_provider_impl.cc View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M content/common/service_worker/embedded_worker_messages.h View 1 chunk +6 lines, -0 lines 0 comments Download
M content/common/service_worker/service_worker_messages.h View 1 2 3 4 5 2 chunks +13 lines, -3 lines 0 comments Download
M content/renderer/service_worker/service_worker_context_client.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M content/renderer/service_worker/service_worker_context_client.cc View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/usecounter-window.html View 1 chunk +5 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/usecounter-worker.js View 1 2 3 4 1 chunk +30 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/usecounter.html View 1 2 3 4 1 chunk +325 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/NavigatorServiceWorker.cpp View 2 1 chunk +10 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.h View 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp View 1 2 3 4 4 chunks +14 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp View 1 chunk +8 lines, -8 lines 0 comments Download
M third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h View 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h View 1 chunk +4 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 124 (102 generated)
nhiroki
PTAL, thanks!
3 years, 10 months ago (2017-02-07 09:32:01 UTC) #72
kinuko
lgtm https://codereview.chromium.org/2658603003/diff/300001/content/child/service_worker/service_worker_dispatcher.cc File content/child/service_worker/service_worker_dispatcher.cc (right): https://codereview.chromium.org/2658603003/diff/300001/content/child/service_worker/service_worker_dispatcher.cc#newcode842 content/child/service_worker/service_worker_dispatcher.cc:842: // Sync controllee's use counter with service worker's ...
3 years, 10 months ago (2017-02-07 13:42:58 UTC) #75
haraken
https://codereview.chromium.org/2658603003/diff/300001/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp File third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp (right): https://codereview.chromium.org/2658603003/diff/300001/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp#newcode367 third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp:367: // to record an API use. Nit: I'd prefer ...
3 years, 10 months ago (2017-02-08 04:28:46 UTC) #77
falken
Does this sync the use counter with the browser and other pages immediately on each ...
3 years, 10 months ago (2017-02-08 05:01:54 UTC) #78
nhiroki
Thanks for your comments. Updated. https://codereview.chromium.org/2658603003/diff/300001/content/browser/service_worker/service_worker_database.proto File content/browser/service_worker/service_worker_database.proto (right): https://codereview.chromium.org/2658603003/diff/300001/content/browser/service_worker/service_worker_database.proto#newcode55 content/browser/service_worker/service_worker_database.proto:55: // blink::UseCounter::Feature enum. On ...
3 years, 10 months ago (2017-02-09 05:11:32 UTC) #87
falken
Did you see my top-level comment too?
3 years, 10 months ago (2017-02-09 05:31:15 UTC) #88
kinuko
On 2017/02/09 05:31:15, falken wrote: > Did you see my top-level comment too? That was ...
3 years, 10 months ago (2017-02-09 05:32:58 UTC) #89
nhiroki
On 2017/02/08 05:01:54, falken wrote: > Does this sync the use counter with the browser ...
3 years, 10 months ago (2017-02-09 05:33:20 UTC) #90
falken
Makes sense to me. lgtm. https://codereview.chromium.org/2658603003/diff/360001/content/browser/service_worker/service_worker_provider_host.h File content/browser/service_worker/service_worker_provider_host.h (right): https://codereview.chromium.org/2658603003/diff/360001/content/browser/service_worker/service_worker_provider_host.h#newcode238 content/browser/service_worker/service_worker_provider_host.h:238: // should be called ...
3 years, 10 months ago (2017-02-09 06:03:58 UTC) #91
nhiroki
+dcheng@, can you review content/common/service_worker/*_messages.h ? I'll address falken@'s comments tomorrow.
3 years, 10 months ago (2017-02-09 15:14:06 UTC) #93
dcheng
https://codereview.chromium.org/2658603003/diff/360001/content/browser/service_worker/service_worker_version.h File content/browser/service_worker/service_worker_version.h (right): https://codereview.chromium.org/2658603003/diff/360001/content/browser/service_worker/service_worker_version.h#newcode470 content/browser/service_worker/service_worker_version.h:470: void set_used_features(std::set<uint32_t> used_features) { Nit: Pass by const ref ...
3 years, 10 months ago (2017-02-09 22:43:20 UTC) #94
darin (slow to review)
I think this introduces the same issue as https://codereview.chromium.org/2586863002/. This CL depends on MessagePort communication ...
3 years, 10 months ago (2017-02-09 23:20:15 UTC) #95
darin (slow to review)
On 2017/02/09 23:20:15, darin (slow to review) wrote: > I think this introduces the same ...
3 years, 10 months ago (2017-02-09 23:26:42 UTC) #96
nhiroki
On 2017/02/09 23:26:42, darin (slow to review) wrote: > On 2017/02/09 23:20:15, darin (slow to ...
3 years, 10 months ago (2017-02-10 00:20:56 UTC) #97
darin (slow to review)
On 2017/02/10 00:20:56, nhiroki (slow) wrote: > On 2017/02/09 23:26:42, darin (slow to review) wrote: ...
3 years, 10 months ago (2017-02-10 00:28:49 UTC) #98
nhiroki
On 2017/02/10 00:28:49, darin (slow to review) wrote: > On 2017/02/10 00:20:56, nhiroki (slow) wrote: ...
3 years, 10 months ago (2017-02-10 15:32:58 UTC) #99
nhiroki
Thank you for the comments. Updated. https://codereview.chromium.org/2658603003/diff/360001/content/browser/service_worker/service_worker_provider_host.h File content/browser/service_worker/service_worker_provider_host.h (right): https://codereview.chromium.org/2658603003/diff/360001/content/browser/service_worker/service_worker_provider_host.h#newcode238 content/browser/service_worker/service_worker_provider_host.h:238: // should be ...
3 years, 10 months ago (2017-02-13 05:42:09 UTC) #104
nhiroki
https://codereview.chromium.org/2658603003/diff/300001/content/browser/service_worker/service_worker_provider_host.cc File content/browser/service_worker/service_worker_provider_host.cc (right): https://codereview.chromium.org/2658603003/diff/300001/content/browser/service_worker/service_worker_provider_host.cc#newcode465 content/browser/service_worker/service_worker_provider_host.cc:465: return; // Could be NULL in some tests. On ...
3 years, 10 months ago (2017-02-13 09:39:40 UTC) #109
dcheng
ipc lgtm https://codereview.chromium.org/2658603003/diff/420001/content/browser/service_worker/service_worker_database.cc File content/browser/service_worker/service_worker_database.cc (right): https://codereview.chromium.org/2658603003/diff/420001/content/browser/service_worker/service_worker_database.cc#newcode1343 content/browser/service_worker/service_worker_database.cc:1343: for (int32_t feature : registration.used_features) Nit: uint32_t ...
3 years, 10 months ago (2017-02-13 21:25:03 UTC) #112
nhiroki
Thank you! https://codereview.chromium.org/2658603003/diff/420001/content/browser/service_worker/service_worker_database.cc File content/browser/service_worker/service_worker_database.cc (right): https://codereview.chromium.org/2658603003/diff/420001/content/browser/service_worker/service_worker_database.cc#newcode1343 content/browser/service_worker/service_worker_database.cc:1343: for (int32_t feature : registration.used_features) On 2017/02/13 ...
3 years, 10 months ago (2017-02-14 02:22:35 UTC) #113
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2658603003/440001
3 years, 10 months ago (2017-02-14 05:11:13 UTC) #121
commit-bot: I haz the power
3 years, 10 months ago (2017-02-14 05:20:41 UTC) #124
Message was sent while issue was closed.
Committed patchset #8 (id:440001) as
https://chromium.googlesource.com/chromium/src/+/38e501dfecb476f9666f3833fd2a...

Powered by Google App Engine
This is Rietveld 408576698