| 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 #ifndef SyncManager_h | 5 #ifndef SyncManager_h |
| 6 #define SyncManager_h | 6 #define SyncManager_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "public/platform/modules/background_sync/background_sync.mojom-blink.h" |
| 10 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 class BackgroundSyncProvider; | |
| 15 class ExecutionContext; | 15 class ExecutionContext; |
| 16 class ScriptPromise; | 16 class ScriptPromise; |
| 17 class ScriptPromiseResolver; |
| 17 class ScriptState; | 18 class ScriptState; |
| 18 class ServiceWorkerRegistration; | 19 class ServiceWorkerRegistration; |
| 19 | 20 |
| 20 class SyncManager final : public GarbageCollected<SyncManager>, | 21 class SyncManager final : public GarbageCollectedFinalized<SyncManager>, |
| 21 public ScriptWrappable { | 22 public ScriptWrappable { |
| 22 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
| 23 | 24 |
| 24 public: | 25 public: |
| 25 static SyncManager* create(ServiceWorkerRegistration* registration) { | 26 static SyncManager* create(ServiceWorkerRegistration* registration) { |
| 26 return new SyncManager(registration); | 27 return new SyncManager(registration); |
| 27 } | 28 } |
| 28 | 29 |
| 29 ScriptPromise registerFunction(ScriptState*, const String& tag); | 30 ScriptPromise registerFunction(ScriptState*, const String& tag); |
| 30 ScriptPromise getTags(ScriptState*); | 31 ScriptPromise getTags(ScriptState*); |
| 31 | 32 |
| 32 DECLARE_TRACE(); | 33 DECLARE_TRACE(); |
| 33 | 34 |
| 34 enum { kUnregisteredSyncID = -1 }; | 35 enum { kUnregisteredSyncID = -1 }; |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 explicit SyncManager(ServiceWorkerRegistration*); | 38 explicit SyncManager(ServiceWorkerRegistration*); |
| 38 | 39 |
| 39 static BackgroundSyncProvider* backgroundSyncProvider(); | 40 // Returns an initialized BackgroundSyncServicePtr. A connection with the |
| 41 // the browser's BackgroundSyncService is created the first time this method |
| 42 // is called. |
| 43 const mojom::blink::BackgroundSyncServicePtr& getBackgroundSyncServicePtr(); |
| 44 |
| 45 // Callbacks |
| 46 static void registerCallback(ScriptPromiseResolver*, |
| 47 mojom::blink::BackgroundSyncError, |
| 48 mojom::blink::SyncRegistrationPtr options); |
| 49 static void getRegistrationsCallback( |
| 50 ScriptPromiseResolver*, |
| 51 mojom::blink::BackgroundSyncError, |
| 52 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); |
| 40 | 53 |
| 41 Member<ServiceWorkerRegistration> m_registration; | 54 Member<ServiceWorkerRegistration> m_registration; |
| 55 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; |
| 42 }; | 56 }; |
| 43 | 57 |
| 44 } // namespace blink | 58 } // namespace blink |
| 45 | 59 |
| 46 #endif // SyncManager_h | 60 #endif // SyncManager_h |
| OLD | NEW |