| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/background_sync/SyncManager.h" | 5 #include "modules/background_sync/SyncManager.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
| 12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/dom/ExecutionContext.h" | 13 #include "core/dom/ExecutionContext.h" |
| 14 #include "modules/background_sync/BackgroundSyncProvider.h" | 14 #include "modules/background_sync/BackgroundSyncProvider.h" |
| 15 #include "modules/background_sync/SyncCallbacks.h" | |
| 16 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 15 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 17 #include "public/platform/Platform.h" | 16 #include "public/platform/Platform.h" |
| 18 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
| 19 #include "wtf/ThreadSpecific.h" | 18 #include "wtf/ThreadSpecific.h" |
| 20 | 19 |
| 21 namespace blink { | 20 namespace blink { |
| 22 | 21 |
| 23 // static | 22 // static |
| 24 BackgroundSyncProvider* SyncManager::backgroundSyncProvider() { | 23 BackgroundSyncProvider* SyncManager::backgroundSyncProvider() { |
| 25 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<BackgroundSyncProvider>, | 24 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<BackgroundSyncProvider>, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 47 ScriptPromise promise = resolver->promise(); | 46 ScriptPromise promise = resolver->promise(); |
| 48 | 47 |
| 49 mojom::blink::SyncRegistrationPtr syncRegistration = | 48 mojom::blink::SyncRegistrationPtr syncRegistration = |
| 50 mojom::blink::SyncRegistration::New(); | 49 mojom::blink::SyncRegistration::New(); |
| 51 syncRegistration->id = SyncManager::kUnregisteredSyncID; | 50 syncRegistration->id = SyncManager::kUnregisteredSyncID; |
| 52 syncRegistration->tag = tag; | 51 syncRegistration->tag = tag; |
| 53 syncRegistration->network_state = | 52 syncRegistration->network_state = |
| 54 blink::mojom::BackgroundSyncNetworkState::ONLINE; | 53 blink::mojom::BackgroundSyncNetworkState::ONLINE; |
| 55 | 54 |
| 56 backgroundSyncProvider()->registerBackgroundSync( | 55 backgroundSyncProvider()->registerBackgroundSync( |
| 57 std::move(syncRegistration), m_registration->webRegistration(), | 56 std::move(syncRegistration), m_registration->webRegistration(), resolver); |
| 58 makeUnique<SyncRegistrationCallbacks>(resolver, m_registration)); | |
| 59 | 57 |
| 60 return promise; | 58 return promise; |
| 61 } | 59 } |
| 62 | 60 |
| 63 ScriptPromise SyncManager::getTags(ScriptState* scriptState) { | 61 ScriptPromise SyncManager::getTags(ScriptState* scriptState) { |
| 64 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 62 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 65 ScriptPromise promise = resolver->promise(); | 63 ScriptPromise promise = resolver->promise(); |
| 66 | 64 |
| 67 backgroundSyncProvider()->getRegistrations( | 65 backgroundSyncProvider()->getRegistrations(m_registration->webRegistration(), |
| 68 m_registration->webRegistration(), | 66 resolver); |
| 69 makeUnique<SyncGetRegistrationsCallbacks>(resolver, m_registration)); | |
| 70 | 67 |
| 71 return promise; | 68 return promise; |
| 72 } | 69 } |
| 73 | 70 |
| 74 DEFINE_TRACE(SyncManager) { | 71 DEFINE_TRACE(SyncManager) { |
| 75 visitor->trace(m_registration); | 72 visitor->trace(m_registration); |
| 76 } | 73 } |
| 77 | 74 |
| 78 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |