Download starts before Callback.Continue is called

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.

Download starts before Callback.Continue is called

Postby jfox » Fri Aug 21, 2020 1:54 pm

My understanding of the way downloads work is that when CefBrowserHost::StartDownload is called, the code defined in DownloadHandler::OnBeforeDownload is executed, but the download shouldn't actually start until CefBeforeDownloadCallback::Continue is called. My code calls Continue outside of the OnBeforeDownload function after some additional processing is done, but I'm noticing that DownloadHandler::OnDownloadUpdated is being called before Continue is ever called, and the update info indicates that the download is in progress and has already read many bytes before Continue is ever called. This is problematic for us because we're relying on some additional processing to be done before the download actually starts. Is this behavior intentional, or this an issue with CEF?
jfox
Newbie
 
Posts: 2
Joined: Fri Aug 21, 2020 1:46 pm

Re: Download starts before Callback.Continue is called

Postby magreenblatt » Fri Aug 21, 2020 2:22 pm

Your understanding is not correct, but understandable given the current OnBeforeDownload documentation. OnBeforeDownload is called from DownloadManagerDelegate::DetermineDownloadTarget in Chromium. The download will eventually be canceled if the CefBeforeDownloadCallback is not executed. This should be clarified in the OnBeforeDownload documentation.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Download starts before Callback.Continue is called

Postby jfox » Fri Aug 21, 2020 2:43 pm

Excellent, that explains a lof of the behaviour I've been seeing. I'm assuming there's nothing that can be done to delay the download once StartDownload is called then?
jfox
Newbie
 
Posts: 2
Joined: Fri Aug 21, 2020 1:46 pm

Re: Download starts before Callback.Continue is called

Postby magreenblatt » Fri Aug 21, 2020 3:09 pm

jfox wrote:I'm assuming there's nothing that can be done to delay the download once StartDownload is called then?

You could delay the download using a CefResourceRequestHandler callback like OnBeforeResourceLoad.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Majestic-12 [Bot] and 24 guests