| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/update_client/url_fetcher_downloader.h" | 5 #include "components/update_client/url_fetcher_downloader.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "components/update_client/utils.h" | 16 #include "components/update_client/utils.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/url_request/url_fetcher.h" | 18 #include "net/url_request/url_fetcher.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 namespace update_client { | 21 namespace update_client { |
| 21 | 22 |
| 22 UrlFetcherDownloader::UrlFetcherDownloader( | 23 UrlFetcherDownloader::UrlFetcherDownloader( |
| 23 std::unique_ptr<CrxDownloader> successor, | 24 std::unique_ptr<CrxDownloader> successor, |
| 24 net::URLRequestContextGetter* context_getter, | 25 net::URLRequestContextGetter* context_getter, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 void UrlFetcherDownloader::DoStartDownload(const GURL& url) { | 36 void UrlFetcherDownloader::DoStartDownload(const GURL& url) { |
| 36 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 37 | 38 |
| 38 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); | 39 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); |
| 39 url_fetcher_->SetRequestContext(context_getter_); | 40 url_fetcher_->SetRequestContext(context_getter_); |
| 40 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 41 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 41 net::LOAD_DO_NOT_SAVE_COOKIES | | 42 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 42 net::LOAD_DISABLE_CACHE); | 43 net::LOAD_DISABLE_CACHE); |
| 43 url_fetcher_->SetAutomaticallyRetryOn5xx(false); | 44 url_fetcher_->SetAutomaticallyRetryOn5xx(false); |
| 44 url_fetcher_->SaveResponseToTemporaryFile(task_runner()); | 45 url_fetcher_->SaveResponseToTemporaryFile(task_runner()); |
| 46 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 47 url_fetcher_.get(), data_use_measurement::DataUseUserData::UPDATE_CLIENT); |
| 45 | 48 |
| 46 VLOG(1) << "Starting background download: " << url.spec(); | 49 VLOG(1) << "Starting background download: " << url.spec(); |
| 47 url_fetcher_->Start(); | 50 url_fetcher_->Start(); |
| 48 | 51 |
| 49 download_start_time_ = base::TimeTicks::Now(); | 52 download_start_time_ = base::TimeTicks::Now(); |
| 50 | 53 |
| 51 downloaded_bytes_ = -1; | 54 downloaded_bytes_ = -1; |
| 52 total_bytes_ = -1; | 55 total_bytes_ = -1; |
| 53 } | 56 } |
| 54 | 57 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 total_bytes_ = total; | 109 total_bytes_ = total; |
| 107 | 110 |
| 108 Result result; | 111 Result result; |
| 109 result.downloaded_bytes = downloaded_bytes_; | 112 result.downloaded_bytes = downloaded_bytes_; |
| 110 result.total_bytes = total_bytes_; | 113 result.total_bytes = total_bytes_; |
| 111 | 114 |
| 112 OnDownloadProgress(result); | 115 OnDownloadProgress(result); |
| 113 } | 116 } |
| 114 | 117 |
| 115 } // namespace update_client | 118 } // namespace update_client |
| OLD | NEW |