| Index: Source/modules/background_sync/SyncManager.cpp
|
| diff --git a/Source/modules/background_sync/SyncManager.cpp b/Source/modules/background_sync/SyncManager.cpp
|
| index 4298bd72e84a6f2e8cff23e7e4fee6ef03cc9e51..6485b61ad15235e16a2becd0d538e826a6ec7749 100644
|
| --- a/Source/modules/background_sync/SyncManager.cpp
|
| +++ b/Source/modules/background_sync/SyncManager.cpp
|
| @@ -25,13 +25,6 @@
|
| namespace blink {
|
| namespace {
|
|
|
| -/* This is the minimum period which will be allowed by the Background
|
| - * Sync manager process. It is recorded here in order to be able to
|
| - * respond to syncManager.minAllowablePeriod.
|
| - * The time is expressed in milliseconds,
|
| - */
|
| -unsigned long kMinAllowablePeriod = 12 * 60 * 60 * 1000;
|
| -
|
| WebSyncProvider* backgroundSyncProvider()
|
| {
|
| WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncProvider();
|
| @@ -47,11 +40,6 @@ SyncManager::SyncManager(ServiceWorkerRegistration* registration)
|
| ASSERT(registration);
|
| }
|
|
|
| -unsigned long SyncManager::minAllowablePeriod()
|
| -{
|
| - return kMinAllowablePeriod;
|
| -}
|
| -
|
| ScriptPromise SyncManager::registerFunction(blink::ScriptState* scriptState, const SyncRegistrationOptions& options)
|
| {
|
| if (!m_registration->active())
|
| @@ -60,19 +48,15 @@ ScriptPromise SyncManager::registerFunction(blink::ScriptState* scriptState, con
|
| RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
|
|
| - WebSyncRegistration::NetworkType networkType;
|
| - String minRequiredNetwork = options.minRequiredNetwork();
|
| - if (minRequiredNetwork == "network-any") {
|
| - networkType = WebSyncRegistration::NetworkType::NetworkTypeAny;
|
| - } else if (minRequiredNetwork == "network-non-mobile") {
|
| - networkType = WebSyncRegistration::NetworkType::NetworkTypeNonMobile;
|
| - } else if (minRequiredNetwork == "network-offline") {
|
| - networkType = WebSyncRegistration::NetworkType::NetworkTypeOffline;
|
| - } else {
|
| - networkType = WebSyncRegistration::NetworkType::NetworkTypeOnline;
|
| - }
|
| - WebSyncRegistration webSyncRegistration(options.id(), options.minDelay(), options.maxDelay(), options.minPeriod(), networkType, options.allowOnBattery(), options.idleRequired());
|
| - backgroundSyncProvider()->registerBackgroundSync(&webSyncRegistration, m_registration->webRegistration(), new SyncRegistrationCallbacks(resolver, m_registration));
|
| + WebSyncRegistration* webSyncRegistration = new WebSyncRegistration(
|
| + WebSyncRegistration::UNREGISTERED_SYNC_ID /* id */,
|
| + WebSyncRegistration::PeriodicityOneShot,
|
| + options.tag(),
|
| + 0 /* minPeriod */,
|
| + WebSyncRegistration::NetworkStateAny /* networkState */,
|
| + WebSyncRegistration::PowerStateAuto /* powerState */
|
| + );
|
| + backgroundSyncProvider()->registerBackgroundSync(webSyncRegistration, m_registration->webRegistration(), new SyncRegistrationCallbacks(resolver, m_registration));
|
|
|
| return promise;
|
| }
|
| @@ -85,7 +69,7 @@ ScriptPromise SyncManager::getRegistration(blink::ScriptState* scriptState, cons
|
| RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
|
|
| - backgroundSyncProvider()->getRegistration(syncRegistrationId, m_registration->webRegistration(), new SyncRegistrationCallbacks(resolver, m_registration));
|
| + backgroundSyncProvider()->getRegistration(blink::WebSyncRegistration::PeriodicityOneShot, syncRegistrationId, m_registration->webRegistration(), new SyncRegistrationCallbacks(resolver, m_registration));
|
|
|
| return promise;
|
| }
|
| @@ -98,8 +82,19 @@ ScriptPromise SyncManager::getRegistrations(blink::ScriptState* scriptState)
|
| RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
|
|
| - backgroundSyncProvider()->getRegistrations(m_registration->webRegistration(), new SyncGetRegistrationsCallbacks(resolver, m_registration));
|
| + backgroundSyncProvider()->getRegistrations(blink::WebSyncRegistration::PeriodicityOneShot, m_registration->webRegistration(), new SyncGetRegistrationsCallbacks(resolver, m_registration));
|
| +
|
| + return promise;
|
| +}
|
|
|
| +ScriptPromise SyncManager::permissionState(blink::ScriptState* scriptState)
|
| +{
|
| + if (!m_registration->active())
|
| + return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(AbortError, "Operation failed - no active Service Worker"));
|
| +
|
| + RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + resolver->resolve(String::fromUTF8("granted"));
|
| return promise;
|
| }
|
|
|
|
|