mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for native creation and resolution of Promises (fixes issue #3305)
This commit is contained in:
committed by
Marshall Greenblatt
parent
60ee4a34aa
commit
fa643b269e
@ -536,6 +536,15 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
|
||||
CefRefPtr<CefV8Handler> handler);
|
||||
|
||||
///
|
||||
/// Create a new CefV8Value object of type Promise. This method should only be
|
||||
/// called from within the scope of a CefRenderProcessHandler, CefV8Handler or
|
||||
/// CefV8Accessor callback, or in combination with calling Enter() and Exit()
|
||||
/// on a stored CefV8Context reference.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefV8Value> CreatePromise();
|
||||
|
||||
///
|
||||
/// Returns true if the underlying handle is valid and it can be accessed on
|
||||
/// the current thread. Do not call any other methods if this method returns
|
||||
@ -616,6 +625,12 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
virtual bool IsFunction() = 0;
|
||||
|
||||
///
|
||||
/// True if the value type is a Promise.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsPromise() = 0;
|
||||
|
||||
///
|
||||
/// Returns true if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
@ -893,6 +908,29 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments) = 0;
|
||||
|
||||
// PROMISE METHODS - These methods are only available on Promises.
|
||||
|
||||
///
|
||||
/// Resolve the Promise using the current V8 context. This method should only
|
||||
/// be called from within the scope of a CefV8Handler or CefV8Accessor
|
||||
/// callback, or in combination with calling Enter() and Exit() on a stored
|
||||
/// CefV8Context reference. |arg| is the argument passed to the resolved
|
||||
/// promise. Returns true on success. Returns false if this method is called
|
||||
/// incorrectly or an exception is thrown.
|
||||
///
|
||||
/*--cef(optional_param=arg)--*/
|
||||
virtual bool ResolvePromise(CefRefPtr<CefV8Value> arg) = 0;
|
||||
|
||||
///
|
||||
/// Reject the Promise using the current V8 context. This method should only
|
||||
/// be called from within the scope of a CefV8Handler or CefV8Accessor
|
||||
/// callback, or in combination with calling Enter() and Exit() on a stored
|
||||
/// CefV8Context reference. Returns true on success. Returns false if this
|
||||
/// method is called incorrectly or an exception is thrown.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool RejectPromise(const CefString& errorMsg) = 0;
|
||||
};
|
||||
|
||||
///
|
||||
|
Reference in New Issue
Block a user