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

Unified Diff: chrome/browser/component_updater/url_fetcher_downloader.cc

Issue 105853002: Implement a background downloader using BITS in Windows Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trybots and Josh's feedback. Created 7 years 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/component_updater/url_fetcher_downloader.cc
diff --git a/chrome/browser/component_updater/url_fetcher_downloader.cc b/chrome/browser/component_updater/url_fetcher_downloader.cc
index d76303aace5852f4c9cc80fdff87a68630ce29a5..d7cf4e1945a4be4697ff29da3cf7b6b0a7f59760 100644
--- a/chrome/browser/component_updater/url_fetcher_downloader.cc
+++ b/chrome/browser/component_updater/url_fetcher_downloader.cc
@@ -14,9 +14,12 @@ using content::BrowserThread;
namespace component_updater {
UrlFetcherDownloader::UrlFetcherDownloader(
+ scoped_ptr<CrxDownloader> successor,
net::URLRequestContextGetter* context_getter,
- scoped_refptr<base::SequencedTaskRunner> task_runner)
- : context_getter_(context_getter),
+ scoped_refptr<base::SequencedTaskRunner> task_runner,
+ const DownloadCallback& download_callback)
+ : CrxDownloader(successor.Pass(), download_callback),
+ context_getter_(context_getter),
task_runner_(task_runner) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
@@ -43,17 +46,20 @@ void UrlFetcherDownloader::DoStartDownload(const GURL& url) {
void UrlFetcherDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // Consider a 5xx response from the server as an indication to terminate
+ // the request and avoid overloading the server in this case.
+ // is not accepting requests for the moment.
const int fetch_error(GetFetchError(*url_fetcher_));
- base::FilePath response;
+ const bool is_handled = fetch_error == 0 || IsHttpServerError(fetch_error);
+
+ Result result;
+ result.error = fetch_error;
+ result.is_background_download = false;
if (!fetch_error) {
- source->GetResponseAsFilePath(true, &response);
+ source->GetResponseAsFilePath(true, &result.response);
}
- // Consider a "503 Service Unavailable" response from the server as an
- // indication to terminate the request and avoid overloading a server which
- // is not accepting requests for the moment.
- const bool is_handled = fetch_error == 0 || fetch_error == 503;
- OnDownloadComplete(is_handled, fetch_error, response);
+ CrxDownloader::OnDownloadComplete(is_handled, result);
}
} // namespace component_updater

Powered by Google App Engine
This is Rietveld 408576698