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

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

Issue 468913007: Add support for CallbackPromiseAdapter<void, T> matching WebCallbacks<void, T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@geofencing5
Patch Set: rebase and add explicit Created 6 years, 4 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 | no next file » | 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 af0f1486dd757c1d3978b4b6de71929ce481c098..9aace9ae4af8e63b71a330d81f5cde68e855993f 100644
--- a/Source/bindings/core/v8/CallbackPromiseAdapter.h
+++ b/Source/bindings/core/v8/CallbackPromiseAdapter.h
@@ -78,7 +78,7 @@ namespace blink {
template<typename S, typename T>
class CallbackPromiseAdapter FINAL : public blink::WebCallbacks<typename S::WebType, typename T::WebType> {
public:
- CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver)
+ explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver)
: m_resolver(resolver)
{
ASSERT(m_resolver);
@@ -108,6 +108,38 @@ private:
WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
};
+template<typename T>
+class CallbackPromiseAdapter<void, T> FINAL : public blink::WebCallbacks<void, typename T::WebType> {
+public:
+ explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver)
+ : m_resolver(resolver)
+ {
+ ASSERT(m_resolver);
+ }
+ virtual ~CallbackPromiseAdapter() { }
+
+ virtual void onSuccess() OVERRIDE
+ {
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ return;
+ }
+ m_resolver->resolve(V8UndefinedType());
+ }
+
+ virtual void onError(typename T::WebType* error) OVERRIDE
+ {
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ T::dispose(error);
+ return;
+ }
+ m_resolver->reject(T::take(m_resolver.get(), error));
+ }
+
+private:
+ RefPtr<ScriptPromiseResolver> m_resolver;
+ WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
+};
+
} // namespace blink
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698