Is CefPostTask defined in cef_task.h still valid

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.

Is CefPostTask defined in cef_task.h still valid

Postby Mayhew » Thu May 05, 2016 7:32 pm

It looks like all code in CefClient has been updated to use Closure vs CefTask and cef_runnable.h has been removed in later branches (2704)
Should bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task); in include\cef_task.h also be removed or is it still valid to use?

John
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm

Re: Is CefPostTask defined in cef_task.h still valid

Postby Mayhew » Thu May 05, 2016 7:50 pm

Hmm, or has that all been left in so you can use existing code with CefCreateClosureTask() and not have to update all of your code that uses CefTask and CefPostTask?

In our case many of our classes that use CefPostTask to call members from other threads wrap CefPostTask in a virtual method called PostTask. This allows us to override that for unit testing. Our unit tests use a helper class that mimics CEFs task runner by starting a thread that calling CefTask::Execute() on the passed task.

I started to update all of my PostTask overrides from
virtual void PostTask(CefThreadId thread_id, CefRefPtr<CefTask> task);
to
virtual void PostTask(CefThreadId thread_id, const base::Closure& closure);

But it seems Closure doesn't have a Run or Execute method that takes no parameters. Instead it is templated and each version has a Run method with a different number of paramters. The only way for our test class to mimic that would be to make it templated as well. Am I missing something there?
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm

Re: Is CefPostTask defined in cef_task.h still valid

Postby magreenblatt » Thu May 05, 2016 8:33 pm

The underlying API is still CefTask. Bind is now used instead of NewRunnable* to wrap the CefTask. Take a look at the CefClosureTask implementation: https://bitbucket.org/chromiumembedded/ ... ew-default
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Is CefPostTask defined in cef_task.h still valid

Postby Mayhew » Fri May 06, 2016 1:36 pm

Okay, good to know.
I assume it is better to simply move my code to use base::Closure as that is the preferred way moving forward.

Finally, I see that DISABLE_RUNNABLE_METHOD_REFCOUNT is no longer defined. Do all classes that have methods that are called from a task now require refcounting?
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm

Re: Is CefPostTask defined in cef_task.h still valid

Postby magreenblatt » Fri May 06, 2016 8:41 pm

Mayhew wrote:Okay, good to know.
I assume it is better to simply move my code to use base::Closure as that is the preferred way moving forward.

Finally, I see that DISABLE_RUNNABLE_METHOD_REFCOUNT is no longer defined. Do all classes that have methods that are called from a task now require refcounting?

No, you can use scoped_ptr (std::unique_ptr), WeakPtr, etc., from the include/base folder.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 27 guests