Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1135)

Unified Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2381023003: Retry WebAPK download if fails for the first time. (Closed)
Patch Set: Merge branch 'master' into hanxi_cl Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/webapk/webapk_installer.cc
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc
index ba03aeafc78163deac95fea00b5de1510f343d9e..403297873b469a9e96ed2854038716e31e891f71 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -402,23 +402,41 @@ void WebApkInstaller::OnCreatedSubDirAndSetPermissions(
return;
}
+ DownloadWebApk(output_dir.AppendASCII(webapk_package_), download_url, true);
+}
+
+void WebApkInstaller::DownloadWebApk(const base::FilePath& output_path,
+ const GURL& download_url,
+ bool retry_if_fails) {
timer_.Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(download_timeout_ms_),
base::Bind(&WebApkInstaller::OnTimeout, weak_ptr_factory_.GetWeakPtr()));
- base::FilePath output_path = output_dir.AppendASCII(webapk_package_);
downloader_.reset(new FileDownloader(
download_url, output_path, true, request_context_getter_,
base::Bind(&WebApkInstaller::OnWebApkDownloaded,
- weak_ptr_factory_.GetWeakPtr(), output_path)));
+ weak_ptr_factory_.GetWeakPtr(),
+ output_path, download_url, retry_if_fails)));
}
void WebApkInstaller::OnWebApkDownloaded(const base::FilePath& file_path,
+ const GURL& download_url,
+ bool retry_if_fails,
FileDownloader::Result result) {
timer_.Stop();
if (result != FileDownloader::DOWNLOADED) {
- OnFailure();
+ if (!retry_if_fails) {
+ OnFailure();
+ return;
+ }
+
+ content::BrowserThread::PostDelayedTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&WebApkInstaller::DownloadWebApk,
+ weak_ptr_factory_.GetWeakPtr(),
+ file_path, download_url, false),
+ base::TimeDelta::FromSeconds(2));
return;
}
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698