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

Unified Diff: Source/modules/background_sync/SyncCallbacks.cpp

Issue 1096503002: [Background Sync] Converting Blink code to the MVP API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Unregister method requires the sync registration tag Created 5 years, 8 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: Source/modules/background_sync/SyncCallbacks.cpp
diff --git a/Source/modules/background_sync/SyncCallbacks.cpp b/Source/modules/background_sync/SyncCallbacks.cpp
index e47f938b370fbbbbe5c8bc2cbb89572aeb297e9b..7227cce555296d3b63105f256f07e15ea4c7d6f3 100644
--- a/Source/modules/background_sync/SyncCallbacks.cpp
+++ b/Source/modules/background_sync/SyncCallbacks.cpp
@@ -6,6 +6,7 @@
#include "modules/background_sync/SyncCallbacks.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "modules/background_sync/PeriodicSyncRegistration.h"
#include "modules/background_sync/SyncError.h"
#include "modules/background_sync/SyncRegistration.h"
#include "modules/serviceworkers/ServiceWorkerRegistration.h"
@@ -35,7 +36,14 @@ void SyncRegistrationCallbacks::onSuccess(WebSyncRegistration* webSyncRegistrati
m_resolver->resolve(v8::Null(m_resolver->scriptState()->isolate()));
return;
}
- m_resolver->resolve(SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration));
+ switch (webSyncRegistration->periodicity) {
+ case WebSyncRegistration::PeriodicityPeriodic:
+ m_resolver->resolve(PeriodicSyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration));
+ break;
+ case WebSyncRegistration::PeriodicityOneShot:
+ m_resolver->resolve(SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration));
+ break;
+ }
}
void SyncRegistrationCallbacks::onError(WebSyncError* error)
@@ -105,14 +113,25 @@ void SyncGetRegistrationsCallbacks::onSuccess(WebVector<WebSyncRegistration*>* w
return;
}
- Vector<SyncRegistration*> syncRegistrations;
- for (size_t i = 0; i < webSyncRegistrations->size(); ++i) {
- WebSyncRegistration* webSyncRegistration = (*webSyncRegistrations)[i];
- SyncRegistration* reg = SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration);
- syncRegistrations.append(reg);
+ if (webSyncRegistrations->size() && (*webSyncRegistrations)[0]->periodicity == blink::WebSyncRegistration::PeriodicityOneShot) {
+ Vector<SyncRegistration*> syncRegistrations;
+ for (size_t i = 0; i < webSyncRegistrations->size(); ++i) {
+ WebSyncRegistration* webSyncRegistration = (*webSyncRegistrations)[i];
+ SyncRegistration* reg = SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration);
+ syncRegistrations.append(reg);
+ }
+ delete(webSyncRegistrations);
+ m_resolver->resolve(syncRegistrations);
+ } else {
+ Vector<PeriodicSyncRegistration*> syncRegistrations;
+ for (size_t i = 0; i < webSyncRegistrations->size(); ++i) {
+ WebSyncRegistration* webSyncRegistration = (*webSyncRegistrations)[i];
+ PeriodicSyncRegistration* reg = PeriodicSyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration);
+ syncRegistrations.append(reg);
+ }
+ delete(webSyncRegistrations);
+ m_resolver->resolve(syncRegistrations);
}
- delete(webSyncRegistrations);
- m_resolver->resolve(syncRegistrations);
}
void SyncGetRegistrationsCallbacks::onError(WebSyncError* error)
« no previous file with comments | « Source/modules/background_sync/ServiceWorkerRegistrationSync.idl ('k') | Source/modules/background_sync/SyncEventInit.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698