Page 1 of 1

Using multitherad under the CefResourceHandler

PostPosted: Thu Dec 22, 2016 4:49 am
by saykou
Is it possible to use multi thread under the Resource handler, the cef application started to behave badly after this, i wonder if it is a problem of thread safety on my underlying code, or is CEF that can't handle mutlithread in this section of the code.

I have something like this.

Code: Select all

      virtual bool ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
         OVERRIDE {
         CEF_REQUIRE_IO_THREAD();
         
                        CefPostTask(TID_FILE, base::Bind(&MyCefResourceHandler::asyncExecute, this, request->GetURL(), callback));
         return true;
      }

      void asyncExecute(std::string url, CefRefPtr<CefCallback> callback)
      {
         std::thread asyncExecute(&MyCefResourceHandler::execute, this, url, callback);
         asyncExecute.detach();
      }
      void execute(std::string url, CefRefPtr<CefCallback> callback) {
         //code
         callback->Continue();
      }


thanks in advance.

Re: Using multitherad under the CefResourceHandler

PostPosted: Thu Dec 22, 2016 6:03 pm
by amaitland
Any method that provides s callback is meant to be used in an asynchronous fashion.

Reading the data in an asynchronous fashion is a little more complicated see https://bitbucket.org/chromiumembedded/ ... ew-default