// The user of URLDownloader must ensure that the construction and operations of an URLDownloader // instance are performed on a same thread. classURLDownloader : public net::URLRequest::Delegate { public: classCompleteCallback { public: virtual ~CompleteCallback() {}
virtualvoidOnDownloadSuccess()= 0;
virtualvoidOnDownloadFailure()= 0; };
// The caller of this constructor must make sure: // - `save_path` is writable; // - the object `callback` refers to is alive during the entire lifecycle of URLDownloader, since // the class itself doesn't acquire the ownership for the `callback`. URLDownloader(const GURL& url, const base::FilePath& save_path, CompleteCallback* callback);
voidOnReadCompleted(net::URLRequest* request, int bytes_read)override;
// Saves received network data (stored in `buf_`) to disk write cache, and writes to disk // if necessary. // It is legal to call this function with 0 passed in as `bytes_received`, when you want to // force flushing cache to disk. voidSaveReceivedChunk(int bytes_received, bool force_write_to_disk);