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

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

Issue 2381023003: Retry WebAPK download if fails for the first time. (Closed)
Patch Set: Created 4 years, 3 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
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..386ff30fcabb0ffd2e0f2868c7408066d51d24b7 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -402,23 +402,42 @@ 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();
+ downloader_.reset();
pkotwicz 2016/10/03 21:30:56 I removed this from the diff. It looks like base:
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') | chrome/browser/android/webapk/webapk_installer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698