Chromium Code Reviews| 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..6c3c5acd5eb46ab790fb2a0ce5a6c8b2c60cf836 100644 |
| --- a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp |
| +++ b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp |
| @@ -11,27 +11,27 @@ |
| #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>); |
| + DCHECK(syncProvider); |
|
iclelland
2016/11/14 18:43:07
I don't think the DCHECK is necessary here
adithyas
2016/11/14 19:51:50
Removed, I had that in for debugging :)
|
| + return syncProvider; |
| } |
| SyncManager::SyncManager(ServiceWorkerRegistration* registration) |
| : m_registration(registration) { |
| - ASSERT(registration); |
| + DCHECK(registration); |
| } |
| ScriptPromise SyncManager::registerFunction(ScriptState* scriptState, |
| @@ -48,13 +48,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 +68,7 @@ ScriptPromise SyncManager::getTags(ScriptState* scriptState) { |
| backgroundSyncProvider()->getRegistrations( |
| m_registration->webRegistration(), |
| - new SyncGetRegistrationsCallbacks(resolver, m_registration)); |
| + makeUnique<SyncGetRegistrationsCallbacks>(resolver, m_registration)); |
| return promise; |
| } |