JavascriptAsyncMethodHandler - Obtain Promise from context on Execute

Previously the promise reference was passed into the handler, now we obtain the reference on demand
This commit is contained in:
amaitland
2018-05-15 15:05:29 +10:00
parent 3f9272ac35
commit 930846eb52
6 changed files with 13 additions and 12 deletions
@@ -7,6 +7,7 @@
#include "../CefSharp.Core/Internals/Messaging/Messages.h"
#include "../CefSharp.Core/Internals/Serialization/Primitives.h"
#include "Serialization/V8Serialization.h"
#include "CefAppUnmanagedWrapper.h"
using namespace CefSharp::Internals::Messaging;
using namespace CefSharp::Internals::Serialization;
@@ -21,8 +22,11 @@ namespace CefSharp
{
auto context = CefV8Context::GetCurrentContext();
auto browser = context->GetBrowser();
auto promiseCreator = context->GetGlobal()->GetValue(CefAppUnmanagedWrapper::kPromiseCreatorFunction);
//this will create a promise and give us the reject/resolve functions {p: Promise, res: resolve(), rej: reject()}
auto promiseData = _promiseCreator->ExecuteFunctionWithContext(context, nullptr, CefV8ValueList());
auto promiseData = promiseCreator->ExecuteFunctionWithContext(context, nullptr, CefV8ValueList());
retval = promiseData->GetValue("p");
auto resolve = promiseData->GetValue("res");