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

Unified Diff: chrome/browser/net/file_downloader.cc

Issue 1308723005: Popular sites on the NTP: re-download popular suggestions once per Chrome run (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@knn_ordering
Patch Set: rebase Created 5 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
« no previous file with comments | « chrome/browser/net/file_downloader.h ('k') | chrome/browser/supervised_user/supervised_user_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/file_downloader.cc
diff --git a/chrome/browser/net/file_downloader.cc b/chrome/browser/net/file_downloader.cc
index d97fa272efa304f2c4378e81c300e1abb40e0c49..1b5c2c26c28c5d61b621559ae644125f74093fad 100644
--- a/chrome/browser/net/file_downloader.cc
+++ b/chrome/browser/net/file_downloader.cc
@@ -21,6 +21,7 @@ const int kNumRetries = 1;
FileDownloader::FileDownloader(const GURL& url,
const base::FilePath& path,
+ bool overwrite,
net::URLRequestContextGetter* request_context,
const DownloadFinishedCallback& callback)
: callback_(callback),
@@ -34,13 +35,17 @@ FileDownloader::FileDownloader(const GURL& url,
path,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
- base::PostTaskAndReplyWithResult(
- BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
- base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN).get(),
- FROM_HERE,
- base::Bind(&base::PathExists, path),
- base::Bind(&FileDownloader::OnFileExistsCheckDone,
- weak_ptr_factory_.GetWeakPtr()));
+ if (overwrite) {
+ fetcher_->Start();
+ } else {
+ base::PostTaskAndReplyWithResult(
+ BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN).get(),
+ FROM_HERE,
+ base::Bind(&base::PathExists, path),
+ base::Bind(&FileDownloader::OnFileExistsCheckDone,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
}
FileDownloader::~FileDownloader() {}
@@ -53,14 +58,16 @@ void FileDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
const net::URLRequestStatus& status = source->GetStatus();
if (!status.is_success()) {
- DLOG(WARNING) << "URLRequestStatus error " << status.error();
+ DLOG(WARNING) << "URLRequestStatus error " << status.error()
+ << " while trying to download " << source->GetURL().spec();
callback_.Run(false);
return;
}
int response_code = source->GetResponseCode();
if (response_code != net::HTTP_OK) {
- DLOG(WARNING) << "HTTP error " << response_code;
+ DLOG(WARNING) << "HTTP error " << response_code
+ << " while trying to download " << source->GetURL().spec();
callback_.Run(false);
return;
}
« no previous file with comments | « chrome/browser/net/file_downloader.h ('k') | chrome/browser/supervised_user/supervised_user_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698