- Code: Select all
class OnSuccessHandler : public CefV8Handler
{
....
}
class PromiseHandler : public CefV8Handler
{
virtual bool Execute(const CefString& name,
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) {
m_wrappedFunction->GetFunctionHandler()->Execute(name, object, arguments, retval, exception);
retval = CefV8Value::CreateObject(NULL); // This object cannot be specified of a particular type
CefRefPtr<CefV8Handler> onSuccessHandler = new OnSuccessHandler();
CefRefPtr<CefV8Value> onSuccessFunction = CefV8Value::CreateFunction("OnSuccess", onSuccessHandler);
retval->SetValue("then", onSuccessFunction, V8_PROPERTY_ATTRIBUTE_NONE);
return true;
}
}
I have a real Promises setup in the browser process in a more typical fashion; I Eval a number of function definitions that use Promises and have a CefMessageRouterBrowserSide::Handler impl that can execute them appropriately. But the CefMessageRouterRendererSide interfaces don't seem to have the same OnQuery methods I use to handle the registered promise functions. Is there a way to get something like that in the renderer process, or is there a way to create objects of a specific type in the renderer similar to what I already have, or is there another approach completely that I'm not seeing?