Loading...
Searching...
No Matches
DownloadListenerabstract

#include <Ultralight/Listener.h>

Overview

User-defined interface to handle download-related events for a View.

You must implement this interface to handle downloads initiated by a View.

See also
View::set_download_listener

Public Member Functions

virtual ~DownloadListener ()
 
virtual DownloadId NextDownloadId (ultralight::View *caller)=0
 Called when the View wants to generate a unique download id.
 
virtual bool OnRequestDownload (ultralight::View *caller, DownloadId id, const String &url)=0
 Called when the View wants to start downloading a resource from the network.
 
virtual void OnBeginDownload (ultralight::View *caller, DownloadId id, const String &url, const String &filename, int64_t expected_content_length)=0
 Called when the View begins downloading a resource from the network.
 
virtual void OnReceiveDataForDownload (ultralight::View *caller, DownloadId id, RefPtr< Buffer > data)=0
 Called when the View receives data for a certain download from the network.
 
virtual void OnFinishDownload (ultralight::View *caller, DownloadId id)=0
 Called when the View finishes downloading a resource from the network.
 
virtual void OnFailDownload (ultralight::View *caller, DownloadId id)=0
 Called when the View fails downloading a resource from the network.
 

Constructor & Destructor Documentation

◆ ~DownloadListener()

virtual ~DownloadListener ( )
inlinevirtual

Member Function Documentation

◆ NextDownloadId()

virtual DownloadId NextDownloadId ( ultralight::View * caller)
pure virtual

Called when the View wants to generate a unique download id.

You should generally return an integer (starting at 0) that is incremented with each call to this callback.

◆ OnBeginDownload()

virtual void OnBeginDownload ( ultralight::View * caller,
DownloadId id,
const String & url,
const String & filename,
int64_t expected_content_length )
pure virtual

Called when the View begins downloading a resource from the network.

The View will not actually write any data to disk, you should open a file for writing yourself and handle the OnReceiveDataForDownload callback below.

◆ OnFailDownload()

virtual void OnFailDownload ( ultralight::View * caller,
DownloadId id )
pure virtual

Called when the View fails downloading a resource from the network.

You should close the associated file and delete it from disk in this callback.

◆ OnFinishDownload()

virtual void OnFinishDownload ( ultralight::View * caller,
DownloadId id )
pure virtual

Called when the View finishes downloading a resource from the network.

You should close the associated file in this callback.

◆ OnReceiveDataForDownload()

virtual void OnReceiveDataForDownload ( ultralight::View * caller,
DownloadId id,
RefPtr< Buffer > data )
pure virtual

Called when the View receives data for a certain download from the network.

This may be called multiple times for each active download as data is streamed in.

You should write the data to the associated file in this callback.

◆ OnRequestDownload()

virtual bool OnRequestDownload ( ultralight::View * caller,
DownloadId id,
const String & url )
pure virtual

Called when the View wants to start downloading a resource from the network.

You should return true to allow the download, or false to block the download.


The documentation for this class was generated from the following file: