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

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: int32_t -> uint32_t 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 did_run_install_event = false;
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 did_run_install_event = true;
15 });
16
17 onmessage = e => {
18 if (e.data.type == 'COUNT_FEATURE') {
19 internals.countFeature(e.data.feature);
20 } else if (e.data.type == 'COUNT_DEPRECATION') {
21 internals.countDeprecation(e.data.feature);
22 } else if (e.data.type == 'CLAIM') {
23 let promise = self.clients.claim()
24 .then(() => e.source.postMessage(
25 {type: 'CLAIMED', restarted: !did_run_install_event}));
26 e.waitUntil(promise);
27 } else if (e.data.type == 'PING') {
28 e.source.postMessage({type: 'PONG'});
29 }
30 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698