Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1173)

Unified Diff: Source/modules/background_sync/SyncCallbacks.h

Issue 963683002: Add IDL and initial Blink API for Background Sync (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add missing serviceWorkerRegistration.syncManager to interface tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/background_sync/SyncCallbacks.h
diff --git a/Source/modules/background_sync/SyncCallbacks.h b/Source/modules/background_sync/SyncCallbacks.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ac1cc83b164d2bbbb73bffff4dda7826ba0b7e8
--- /dev/null
+++ b/Source/modules/background_sync/SyncCallbacks.h
@@ -0,0 +1,83 @@
+// 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.
+
+#ifndef SyncCallbacks_h
+#define SyncCallbacks_h
+
+#include "platform/heap/Handle.h"
+#include "public/platform/WebCallbacks.h"
+#include "public/platform/modules/background_sync/WebSyncProvider.h"
+#include "public/platform/modules/background_sync/WebSyncRegistration.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace blink {
+
+class ServiceWorkerRegistration;
+class ScriptPromiseResolver;
+struct WebSyncError;
+struct WebSyncRegistration;
+class WebString;
+
+using WebSyncGetRegistrationsCallbacks = WebCallbacks<WebVector<WebSyncRegistration>, WebSyncError>;
+
+// 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 SyncRegistration.
+class SyncRegistrationCallbacks final : public WebCallbacks<WebSyncRegistration, WebSyncError> {
+ WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks);
+public:
+ SyncRegistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, ServiceWorkerRegistration*);
+ ~SyncRegistrationCallbacks() 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;
+ Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
+};
+
+// SyncGetRegistrationsCallbacks is an implementation of WebSyncGetRegistrationsCallbacks
+// 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 SyncRegistration.
+class SyncGetRegistrationsCallbacks final : public WebCallbacks<WebVector<WebSyncRegistration>, WebSyncError> {
+ WTF_MAKE_NONCOPYABLE(SyncGetRegistrationsCallbacks);
+public:
+ SyncGetRegistrationsCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, ServiceWorkerRegistration*);
+ ~SyncGetRegistrationsCallbacks() override;
+
+ void onSuccess(WebVector<WebSyncRegistration>*) override;
+ void onError(WebSyncError*) override;
+
+private:
+ RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
+ Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
+};
+
+} // namespace blink
+
+#endif // SyncCallbacks_h
« no previous file with comments | « Source/modules/background_sync/ServiceWorkerRegistrationSync.idl ('k') | Source/modules/background_sync/SyncCallbacks.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698