Index: Source/modules/background_sync/SyncManager.cpp |
diff --git a/Source/modules/background_sync/SyncManager.cpp b/Source/modules/background_sync/SyncManager.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a3e0acc0aaaa8fcae7cc9cd230ef7c1dad74feda |
--- /dev/null |
+++ b/Source/modules/background_sync/SyncManager.cpp |
@@ -0,0 +1,75 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/background_sync/SyncManager.h" |
+ |
+#include "bindings/core/v8/CallbackPromiseAdapter.h" |
+#include "bindings/core/v8/ScriptPromise.h" |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "bindings/core/v8/ScriptState.h" |
+#include "core/dom/DOMException.h" |
+#include "core/dom/Document.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "core/dom/ExecutionContext.h" |
+#include "modules/background_sync/SyncCallbacks.h" |
+#include "modules/background_sync/SyncRegistrationOptions.h" |
+#include "modules/serviceworkers/ServiceWorkerRegistration.h" |
+#include "public/platform/Platform.h" |
+#include "public/platform/modules/background_sync/WebSyncProvider.h" |
+#include "wtf/RefPtr.h" |
+ |
+ |
+namespace blink { |
+namespace { |
+ |
+ unsigned long kMinAllowablePeriod = 60000; |
+ |
+ WebSyncProvider* backgroundSyncProvider() |
+ { |
+ WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncProvider(); |
+ ASSERT(webSyncProvider); |
+ return webSyncProvider; |
+ } |
+ |
+} |
+ |
+SyncManager::SyncManager(ServiceWorkerRegistration* registration) |
+ : m_registration(registration) |
+{ |
+ ASSERT(registration); |
+} |
+ |
+unsigned long SyncManager::minAllowablePeriod() |
+{ |
+ return kMinAllowablePeriod; |
+} |
+ |
+ScriptPromise SyncManager::registerFunction(blink::ScriptState* scriptState, const SyncRegistrationOptions& options) |
+{ |
+ RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ |
+ backgroundSyncProvider()->registerBackgroundSync(0, new SyncRegistrationCallbacks(resolver, m_registration)); |
Michael van Ouwerkerk
2015/03/02 14:19:11
What is the magic 0 for?
Michael van Ouwerkerk
2015/03/02 14:19:11
The Push API has a separate path for this function
iclelland
2015/03/05 04:32:48
For temporary. I've added the code now that create
iclelland
2015/03/05 04:32:48
Register wasn't going to be available in the servi
|
+ |
+ return promise; |
+} |
+ |
+ScriptPromise SyncManager::getRegistrations(blink::ScriptState* scriptState) |
+{ |
+ RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ |
+ // Don't have anything useful to do ATM |
+ resolver->reject(DOMException::create(NotSupportedError, "Not implemented")); |
+ |
+ return promise; |
+} |
+ |
+DEFINE_TRACE(SyncManager) |
+{ |
+ visitor->trace(m_registration); |
+} |
+ |
+} // namespace blink |