CefCreateClosureTask with lambdas and Functors

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.

CefCreateClosureTask with lambdas and Functors

Postby JozefK » Fri Mar 03, 2017 5:18 am

Hi, is there any way how to use CefPostTask with lambdas and functors
fe. something like pseudocode here:
Code: Select all
 
      {
         auto cookieDeleteFunc = []()
         {
            CefRefPtr<CefCookieManager> manager = GetCookiesManager();
            if (manager)
               manager->DeleteCookies("", "", nullptr);
         };

         CefPostTask(TID_IO, CefCreateClosureTask(base::Bind(&cookieDeleteFunc)));
      }
      
      
         class CefCookieDeleter
         {
         public:
            void operator()()
            {
               CefRefPtr<CefCookieManager> manager = GetCookiesManager();
               if (manager)
                  manager->DeleteCookies("", "", nullptr);
            }
         };
         
         static CefCookieDeleter functor;
         CefPostTask(TID_IO, CefCreateClosureTask(base::Bind(functor)));

JozefK
Techie
 
Posts: 20
Joined: Mon Feb 27, 2017 3:24 pm

Re: CefCreateClosureTask with lambdas and Functors

Postby magreenblatt » Fri Mar 03, 2017 11:44 am

The CEF API maintains compatibility with C++99 so you would need to write your own CefTask wrapper to support lambdas. For example, look at how the CefCreateClosureTask function is implemented: https://bitbucket.org/chromiumembedded/ ... ew-default
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: CefCreateClosureTask with lambdas and Functors

Postby JozefK » Mon Mar 06, 2017 7:15 am

Oh, I got it. I was just curious. Thank you for the hint.
JozefK
Techie
 
Posts: 20
Joined: Mon Feb 27, 2017 3:24 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 51 guests