Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "modules/background_sync/SyncManager.h" | |
| 7 | |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | |
| 9 #include "bindings/core/v8/ScriptPromise.h" | |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 11 #include "bindings/core/v8/ScriptState.h" | |
| 12 #include "core/dom/DOMException.h" | |
| 13 #include "core/dom/Document.h" | |
| 14 #include "core/dom/ExceptionCode.h" | |
| 15 #include "core/dom/ExecutionContext.h" | |
| 16 #include "modules/background_sync/SyncCallbacks.h" | |
| 17 #include "modules/background_sync/SyncRegistrationOptions.h" | |
| 18 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | |
| 19 #include "public/platform/Platform.h" | |
| 20 #include "public/platform/modules/background_sync/WebSyncProvider.h" | |
| 21 #include "wtf/RefPtr.h" | |
| 22 | |
| 23 | |
| 24 namespace blink { | |
| 25 namespace { | |
| 26 | |
| 27 unsigned long kMinAllowablePeriod = 60000; | |
| 28 | |
| 29 WebSyncProvider* backgroundSyncProvider() | |
| 30 { | |
| 31 WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncPr ovider(); | |
| 32 ASSERT(webSyncProvider); | |
| 33 return webSyncProvider; | |
| 34 } | |
| 35 | |
| 36 } | |
| 37 | |
| 38 SyncManager::SyncManager(ServiceWorkerRegistration* registration) | |
| 39 : m_registration(registration) | |
| 40 { | |
| 41 ASSERT(registration); | |
| 42 } | |
| 43 | |
| 44 unsigned long SyncManager::minAllowablePeriod() | |
| 45 { | |
| 46 return kMinAllowablePeriod; | |
| 47 } | |
| 48 | |
| 49 ScriptPromise SyncManager::registerFunction(blink::ScriptState* scriptState, con st SyncRegistrationOptions& options) | |
| 50 { | |
| 51 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); | |
| 52 ScriptPromise promise = resolver->promise(); | |
| 53 | |
| 54 backgroundSyncProvider()->registerBackgroundSync(0, new SyncRegistrationCall backs(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
| |
| 55 | |
| 56 return promise; | |
| 57 } | |
| 58 | |
| 59 ScriptPromise SyncManager::getRegistrations(blink::ScriptState* scriptState) | |
| 60 { | |
| 61 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); | |
| 62 ScriptPromise promise = resolver->promise(); | |
| 63 | |
| 64 // Don't have anything useful to do ATM | |
| 65 resolver->reject(DOMException::create(NotSupportedError, "Not implemented")) ; | |
| 66 | |
| 67 return promise; | |
| 68 } | |
| 69 | |
| 70 DEFINE_TRACE(SyncManager) | |
| 71 { | |
| 72 visitor->trace(m_registration); | |
| 73 } | |
| 74 | |
| 75 } // namespace blink | |
| OLD | NEW |