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

Unified Diff: Source/bindings/core/v8/CallbackPromiseAdapter.h

Issue 1018613003: Introduce Blink APIs for supporting ServiceWorkerRegistration.getNotifications() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « no previous file | public/platform/modules/notifications/WebNotificationManager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/CallbackPromiseAdapter.h
diff --git a/Source/bindings/core/v8/CallbackPromiseAdapter.h b/Source/bindings/core/v8/CallbackPromiseAdapter.h
index d101c685b621873ebf9cfc8453d77b7116be68ae..55b41c969d0aef1eb23e2defae49e9a7b698b81e 100644
--- a/Source/bindings/core/v8/CallbackPromiseAdapter.h
+++ b/Source/bindings/core/v8/CallbackPromiseAdapter.h
@@ -144,6 +144,37 @@ private:
RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
};
+template<typename S>
+class CallbackPromiseAdapter<S, void> final : public blink::WebCallbacks<typename S::WebType, void> {
+ WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
+public:
+ explicit CallbackPromiseAdapter(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver)
+ : m_resolver(resolver)
+ {
+ ASSERT(m_resolver);
+ }
+ virtual ~CallbackPromiseAdapter() { }
+
+ virtual void onSuccess(typename S::WebType* result) override
+ {
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ S::dispose(result);
+ return;
+ }
+ m_resolver->resolve(S::take(m_resolver.get(), result));
+ }
+
+ virtual void onError() override
+ {
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped())
+ return;
+ m_resolver->reject();
+ }
+
+private:
+ RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
+};
+
template<typename T>
class CallbackPromiseAdapter<bool, T> final : public blink::WebCallbacks<bool, typename T::WebType> {
WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
« no previous file with comments | « no previous file | public/platform/modules/notifications/WebNotificationManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698