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

Unified Diff: content/test/data/background_sync/service_worker.js

Issue 1358063004: Use mojo to connect to BackgroundSyncManager object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make platform impl control cleanup of main thread provider Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/test/data/background_sync/service_worker.js
diff --git a/content/test/data/background_sync/service_worker.js b/content/test/data/background_sync/service_worker.js
index 68f57b55e5e45817b495c90f962a1ef605cac34d..bcd0c7a2d0401a5b17fe4e04c8701eeb6479a513 100644
--- a/content/test/data/background_sync/service_worker.js
+++ b/content/test/data/background_sync/service_worker.js
@@ -52,6 +52,39 @@ this.onmessage = function(event) {
})
.catch(sendSyncErrorToClients);
}
+
+ if (event.data['action'] === 'registerOneShot') {
+ var tag = event.data['tag'];
+ registration.sync.register({'tag': tag})
+ .then(function (syncRegistration) {
+ sendMessageToClients('register', 'ok - ' + tag + ' registered in SW');
+ })
+ .catch(sendSyncErrorToClients);
+ }
+
+ if (event.data['action'] === 'getRegistrationOneShot') {
+ var tag = event.data['tag'];
+ registration.sync.getRegistration(tag)
+ .then(function(syncRegistration) {
+ if (!syncRegistration) {
+ sendMessageToClients('register', 'error - ' + tag + ' not found');
+ return;
+ }
+ sendMessageToClients('register', 'ok - ' + tag + ' found');
+ })
+ .catch(sendSyncErrorToClients);
+ }
+
+ if (event.data['action'] === 'getRegistrationsOneShot') {
+ registration.sync.getRegistrations()
+ .then(function(syncRegistrations) {
+ var tags = syncRegistrations.map(function(syncRegistration) {
+ return syncRegistration.tag;
+ });
+ sendMessageToClients('register', 'ok - ' + tags.toString());
+ })
+ .catch(sendSyncErrorToClients);
+ }
}
this.onsync = function(event) {

Powered by Google App Engine
This is Rietveld 408576698