Returning a value to V8 Handler from the browser process

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Returning a value to V8 Handler from the browser process

Postby palaver » Fri May 19, 2017 4:18 am

The method signature for the CefV8Handler::Execute() method looks like this:
Code: Select all
virtual bool Execute(const CefString& name,
    CefRefPtr<CefV8Value> object,
    const CefV8ValueList& arguments,
    CefRefPtr<CefV8Value>& retval,
    CefString& exception) OVERRIDE


I'd like to be able to do some work in the browser process, and then get back to the render process and assign a value to
Code: Select all
retval
. At the moment what I do is execute the function from javascript, pass some data to the browser process, and return immediately. After that the browser process does some work and passes the value back using a different javascript function.
palaver
Techie
 
Posts: 36
Joined: Wed Nov 25, 2015 9:51 am

Re: Returning a value to V8 Handler from the browser process

Postby Czarek » Thu May 25, 2017 12:20 pm

Due to Chromium's multi-process architecture data should be returned in an asynchronous way using function callbacks. You can pass a callback from javascript, save it in the Renderer process in C++ code, communicate with the browser process and back to the renderer process and execute the saved callback.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 30 guests