Chromium Code Reviews| Index: Source/modules/background_sync/SyncRegistrationCallbacks.h |
| diff --git a/Source/modules/push_messaging/PushSubscriptionCallbacks.h b/Source/modules/background_sync/SyncRegistrationCallbacks.h |
| similarity index 32% |
| copy from Source/modules/push_messaging/PushSubscriptionCallbacks.h |
| copy to Source/modules/background_sync/SyncRegistrationCallbacks.h |
| index 75cd6d3ddf727f9ddefb006b9e6f5c5646130daf..6d15b63b33284b0378dc89dbe3e7cbdd769140d0 100644 |
| --- a/Source/modules/push_messaging/PushSubscriptionCallbacks.h |
| +++ b/Source/modules/background_sync/SyncRegistrationCallbacks.h |
| @@ -1,9 +1,9 @@ |
| -// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
|
jkarlin
2015/02/27 20:08:13
This filename seems a bit off. Perhaps SyncCallbac
iclelland
2015/03/02 03:51:12
Agreed -- it held only the registration callbacks
|
| -#ifndef PushSubscriptionCallbacks_h |
| -#define PushSubscriptionCallbacks_h |
| +#ifndef SyncRegistrationCallbacks_h |
| +#define SyncRegistrationCallbacks_h |
| #include "platform/heap/Handle.h" |
| #include "public/platform/WebCallbacks.h" |
| @@ -15,21 +15,40 @@ namespace blink { |
| class ServiceWorkerRegistration; |
| class ScriptPromiseResolver; |
| -struct WebPushError; |
| -struct WebPushSubscription; |
| +struct WebSyncError; |
| +struct WebSyncRegistration; |
| -// PushSubscriptionCallbacks is an implementation of WebPushSubscriptionCallbacks |
| +// SyncRegistrationCallbacks is an implementation of WebSyncRegistrationCallbacks |
| // that will resolve the underlying promise depending on the result passed to |
| // the callback. It takes a ServiceWorkerRegistration in its constructor and |
| -// will pass it to the PushSubscription. |
| -class PushSubscriptionCallbacks final : public WebCallbacks<WebPushSubscription, WebPushError> { |
| - WTF_MAKE_NONCOPYABLE(PushSubscriptionCallbacks); |
| +// will pass it to the SyncProvider. |
| +class SyncRegistrationCallbacks final : public WebCallbacks<WebSyncRegistration, WebSyncError> { |
| + WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks); |
| public: |
| - PushSubscriptionCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, ServiceWorkerRegistration*); |
| - ~PushSubscriptionCallbacks() override; |
| + SyncRegistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, ServiceWorkerRegistration*); |
| + ~SyncRegistrationCallbacks() override; |
| - void onSuccess(WebPushSubscription*) override; |
| - void onError(WebPushError*) override; |
| + void onSuccess(WebSyncRegistration*) override; |
| + void onError(WebSyncError*) override; |
| + |
| +private: |
| + RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| + Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; |
| +}; |
| + |
| +// SyncUnregistrationCallbacks is an implementation of |
| +// WebSyncUnregistrationCallbacks that will resolve the underlying promise |
| +// depending on the result passed to the callback. It takes a |
| +// ServiceWorkerRegistration in its constructor and will pass it to the |
| +// SyncProvider. |
| +class SyncUnregistrationCallbacks final : public WebCallbacks<bool, WebSyncError> { |
| + WTF_MAKE_NONCOPYABLE(SyncUnregistrationCallbacks); |
| +public: |
| + SyncUnregistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, ServiceWorkerRegistration*); |
| + ~SyncUnregistrationCallbacks() override; |
| + |
| + void onSuccess(bool*) override; |
| + void onError(WebSyncError*) override; |
| private: |
| RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| @@ -38,4 +57,4 @@ private: |
| } // namespace blink |
| -#endif // PushSubscriptionCallbacks_h |
| +#endif // SyncRegistrationCallbacks_h |