Commit ec4f918d authored by Min Qin's avatar Min Qin Committed by Commit Bot

Allow InProgressDownloadManager to resume download

This CL allows InProgressDownloadManager to take a URLLoaderFactoryGetter,
and resume the download by itself.

BUG=842245

Change-Id: Ie2e6dff715455ee8449be05d49c43144de8d25c8
Reviewed-on: https://chromium-review.googlesource.com/1102885Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568729}
parent 96a75a69
......@@ -314,7 +314,13 @@ void InProgressDownloadManager::DetermineDownloadTarget(
void InProgressDownloadManager::ResumeInterruptedDownload(
std::unique_ptr<DownloadUrlParameters> params,
const GURL& site_url) {}
const GURL& site_url) {
if (!url_loader_factory_getter_)
return;
BeginDownload(std::move(params), url_loader_factory_getter_, false, site_url,
GURL(), GURL());
}
base::Optional<DownloadEntry> InProgressDownloadManager::GetInProgressEntry(
DownloadItemImpl* download) {
......
......@@ -128,6 +128,11 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
}
DownloadFileFactory* file_factory() { return file_factory_.get(); }
void set_url_loader_factory_getter(
scoped_refptr<DownloadURLLoaderFactoryGetter> url_loader_factory_getter) {
url_loader_factory_getter_ = std::move(url_loader_factory_getter);
}
private:
// UrlDownloadHandler::Delegate implementations.
void OnUrlDownloadStarted(
......@@ -179,6 +184,10 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
// is managing all downloads.
std::vector<std::unique_ptr<DownloadItemImpl>> in_progress_downloads_;
// URLLoaderFactoryGetter for issuing network request when DownloadMangerImpl
// is not available.
scoped_refptr<DownloadURLLoaderFactoryGetter> url_loader_factory_getter_;
base::WeakPtrFactory<InProgressDownloadManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InProgressDownloadManager);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment