Page 1 of 1

Handler in libcef_dll_wrapper

PostPosted: Fri May 31, 2019 1:31 pm
by yuuGeek
Hi there,
I am working on a swift project which needs to use the message router in the libcef_dll_wrapper. I did all the bridging including the capi and cpptoc classes. But there are several APIs in CefMessageRouterBrowserSide class:
Code: Select all
virtual bool AddHandler(Hanlder* handler, bool first) = 0;
virtual bool RemoveHandler(Hanlder* handler) = 0;
virtual void CancelPending(CefRefPtr<CefBrowser> browser,
                             Hanlder* handler) = 0;
virtual int GetPendingCount(CefRefPtr<CefBrowser> browser,
                              Hanlder* handler) = 0;

Seems the Handler param in these functions is raw pointer instead of CefRefPtr. Which makes the bridging painful.
I saw that the Hanlder is based on CefBaseRefCounted, so is it possible that we use the refptr instead of raw pointers? For example:
Code: Select all
virtual bool AddHandler(CefRefPtr<Handler> handler, bool first) = 0;

I have made the changes in libcef_dll_wrapper project on my local machine, and it works fine.
But I believe such change will effect the client_handler class and several testing classes outside libcef_dll_wrapper. I can try to get them changed together and make a pull request if possible.

Re: Handler in libcef_dll_wrapper

PostPosted: Fri May 31, 2019 2:18 pm
by magreenblatt
Handler is not ref-counted, and this is intentional. Sources that are only inside of libcef_dll_wrapper are C++ sources by design. You can create your own version of CefMessageRouter in swift code without relying on the libcef_dll_wrapper version.

Re: Handler in libcef_dll_wrapper

PostPosted: Mon Jun 03, 2019 10:02 am
by yuuGeek
OK, is there any risk if I make the hanlder ref counted? Since you said it' intentionally not ref counted.

Re: Handler in libcef_dll_wrapper

PostPosted: Mon Jun 03, 2019 10:30 am
by magreenblatt
yuuGeek wrote:OK, is there any risk if I make the hanlder ref counted? Since you said it' intentionally not ref counted.

Nothing that I would consider out of the ordinary.