| Index: third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
|
| diff --git a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
|
| index 9711c0060e47bbbb47379e5e0856d9fe47721a01..16b5bd8664a86d55cac9f0873bfd390fe91dce00 100644
|
| --- a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
|
| +++ b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
|
| @@ -11,27 +11,26 @@
|
| #include "core/dom/DOMException.h"
|
| #include "core/dom/ExceptionCode.h"
|
| #include "core/dom/ExecutionContext.h"
|
| +#include "modules/background_sync/BackgroundSyncProvider.h"
|
| #include "modules/background_sync/SyncCallbacks.h"
|
| #include "modules/serviceworkers/ServiceWorkerRegistration.h"
|
| #include "public/platform/Platform.h"
|
| -#include "public/platform/modules/background_sync/WebSyncProvider.h"
|
| -#include "public/platform/modules/background_sync/WebSyncRegistration.h"
|
| -#include "wtf/RefPtr.h"
|
| +#include "wtf/PtrUtil.h"
|
| +#include "wtf/ThreadSpecific.h"
|
|
|
| namespace blink {
|
| -namespace {
|
|
|
| -WebSyncProvider* backgroundSyncProvider() {
|
| - WebSyncProvider* webSyncProvider =
|
| - Platform::current()->backgroundSyncProvider();
|
| - ASSERT(webSyncProvider);
|
| - return webSyncProvider;
|
| -}
|
| +// static
|
| +BackgroundSyncProvider* SyncManager::backgroundSyncProvider() {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<BackgroundSyncProvider>,
|
| + syncProvider,
|
| + new ThreadSpecific<BackgroundSyncProvider>);
|
| + return syncProvider;
|
| }
|
|
|
| SyncManager::SyncManager(ServiceWorkerRegistration* registration)
|
| : m_registration(registration) {
|
| - ASSERT(registration);
|
| + DCHECK(registration);
|
| }
|
|
|
| ScriptPromise SyncManager::registerFunction(ScriptState* scriptState,
|
| @@ -48,13 +47,16 @@ ScriptPromise SyncManager::registerFunction(ScriptState* scriptState,
|
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
|
|
| - WebSyncRegistration* webSyncRegistration = new WebSyncRegistration(
|
| - WebSyncRegistration::UNREGISTERED_SYNC_ID /* id */, tag,
|
| - WebSyncRegistration::NetworkStateOnline /* networkState */
|
| - );
|
| + mojom::blink::SyncRegistrationPtr syncRegistration =
|
| + mojom::blink::SyncRegistration::New();
|
| + syncRegistration->id = SyncManager::kUnregisteredSyncID;
|
| + syncRegistration->tag = tag;
|
| + syncRegistration->network_state =
|
| + blink::mojom::BackgroundSyncNetworkState::ONLINE;
|
| +
|
| backgroundSyncProvider()->registerBackgroundSync(
|
| - webSyncRegistration, m_registration->webRegistration(),
|
| - new SyncRegistrationCallbacks(resolver, m_registration));
|
| + std::move(syncRegistration), m_registration->webRegistration(),
|
| + makeUnique<SyncRegistrationCallbacks>(resolver, m_registration));
|
|
|
| return promise;
|
| }
|
| @@ -65,7 +67,7 @@ ScriptPromise SyncManager::getTags(ScriptState* scriptState) {
|
|
|
| backgroundSyncProvider()->getRegistrations(
|
| m_registration->webRegistration(),
|
| - new SyncGetRegistrationsCallbacks(resolver, m_registration));
|
| + makeUnique<SyncGetRegistrationsCallbacks>(resolver, m_registration));
|
|
|
| return promise;
|
| }
|
|
|