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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/usecounter-worker.js

Issue 2658603003: ServiceWorker: Enable UseCounter for ServiceWorkerGlobalScope (Closed)
Patch Set: ready to review Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // This should be accessed only in the install event or the message event. When
2 // this is false, it implies that this service worker is restarted after the
3 // install event.
4 let run_install_event = false;
falken 2017/02/08 05:01:54 nit: maybe did_install or did_run_install_event is
nhiroki 2017/02/09 05:11:32 Done.
5
6 self.addEventListener('install', e => {
7 var scope = new URL(self.registration.scope);
8 if (scope.searchParams.get('type') == 'features-during-install') {
9 internals.countFeature(scope.searchParams.get('feature'));
10 internals.countDeprecation(scope.searchParams.get('deprecated'));
11 } else if (scope.searchParams.get('type') == 'skip-waiting') {
12 e.waitUntil(self.skipWaiting());
13 }
14 run_install_event = true;
15 });
16
17 onmessage = e => {
18 if (e.data.type == 'COUNT_FEATURE') {
19 internals.countFeature(e.data.feature);
20 e.source.postMessage({type: 'COUNTED'});
21 } else if (e.data.type == 'COUNT_DEPRECATION') {
22 internals.countDeprecation(e.data.feature);
23 e.source.postMessage({type: 'COUNTED'});
24 } else if (e.data.type == 'CLAIM') {
25 let promise = self.clients.claim()
26 .then(() => e.source.postMessage(
27 {type: 'CLAIMED', restarted: !run_install_event}));
28 e.waitUntil(promise);
29 }
30 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698