Chromium Code Reviews| Index: Source/bindings/core/v8/CallbackPromiseAdapter.h |
| diff --git a/Source/bindings/core/v8/CallbackPromiseAdapter.h b/Source/bindings/core/v8/CallbackPromiseAdapter.h |
| index 0426982e207b4b1f0d0a8e3e160675f3d104c9bb..eb35b757d14da37b7a1bb2c0bd8b25da3c346c53 100644 |
| --- a/Source/bindings/core/v8/CallbackPromiseAdapter.h |
| +++ b/Source/bindings/core/v8/CallbackPromiseAdapter.h |
| @@ -60,6 +60,13 @@ namespace WebCore { |
| // resolver->promise().then(...); |
| // } |
| // |
| +// // Called when aborting to resolve/reject a promise due to an empty |
| +// // execution context. |
| +// static void dispose(blink::WebMyClass* webInstance) { |
| +// // delete as appropriate, but often it's just: |
| +// delete webInstance; |
| +// } |
| +// |
| // Now when calling into a WebKit API that requires a WebCallbacks<blink::WebMyClass, blink::WebMyClass>*: |
| // |
| // // call signature: callSomeMethod(WebCallbacks<MyClass, MyClass>* callbacks) |
| @@ -79,12 +86,22 @@ public: |
| virtual void onSuccess(typename S::WebType* result) OVERRIDE |
| { |
| + if (!m_resolver || !m_resolver->executionContext()) { |
|
yhirano
2014/07/18 09:00:02
m_resolver cannot be null (you can add ASSERT(m_re
nhiroki
2014/07/18 10:28:56
Done.
|
| + S::dispose(result); |
| + return; |
| + } |
| m_resolver->resolve(S::from(m_resolver.get(), result)); |
| } |
| + |
| virtual void onError(typename T::WebType* error) OVERRIDE |
| { |
| + if (!m_resolver || !m_resolver->executionContext()) { |
|
yhirano
2014/07/18 09:00:02
ditto
nhiroki
2014/07/18 10:28:56
Done.
|
| + T::dispose(error); |
| + return; |
| + } |
| m_resolver->reject(T::from(m_resolver.get(), error)); |
| } |
| + |
| private: |
| RefPtr<ScriptPromiseResolver> m_resolver; |
| WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); |