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

Side by Side Diff: components/update_client/crx_downloader.cc

Issue 808773005: Move most of the component updater artifacts to update_client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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/component_updater/crx_downloader.h" 5 #include "components/update_client/crx_downloader.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "components/component_updater/url_fetcher_downloader.h" 10 #include "components/update_client/url_fetcher_downloader.h"
11 11
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 #include "components/component_updater/background_downloader_win.h" 13 #include "components/update_client/background_downloader_win.h"
14 #endif 14 #endif
15 15
16 namespace component_updater { 16 namespace update_client {
17 17
18 CrxDownloader::Result::Result() 18 CrxDownloader::Result::Result()
19 : error(0), downloaded_bytes(-1), total_bytes(-1) { 19 : error(0), downloaded_bytes(-1), total_bytes(-1) {
20 } 20 }
21 21
22 CrxDownloader::DownloadMetrics::DownloadMetrics() 22 CrxDownloader::DownloadMetrics::DownloadMetrics()
23 : downloader(kNone), 23 : downloader(kNone),
24 error(0), 24 error(0),
25 downloaded_bytes(-1), 25 downloaded_bytes(-1),
26 total_bytes(-1), 26 total_bytes(-1),
27 download_time_ms(0) { 27 download_time_ms(0) {
28 } 28 }
29 29
30 // On Windows, the first downloader in the chain is a background downloader, 30 // On Windows, the first downloader in the chain is a background downloader,
31 // which uses the BITS service. 31 // which uses the BITS service.
32 CrxDownloader* CrxDownloader::Create( 32 CrxDownloader* CrxDownloader::Create(
33 bool is_background_download, 33 bool is_background_download,
34 net::URLRequestContextGetter* context_getter, 34 net::URLRequestContextGetter* context_getter,
35 scoped_refptr<base::SequencedTaskRunner> url_fetcher_task_runner, 35 scoped_refptr<base::SequencedTaskRunner> url_fetcher_task_runner,
36 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner) { 36 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner) {
37 scoped_ptr<CrxDownloader> url_fetcher_downloader( 37 scoped_ptr<CrxDownloader> url_fetcher_downloader(
38 new UrlFetcherDownloader(scoped_ptr<CrxDownloader>().Pass(), 38 new UrlFetcherDownloader(scoped_ptr<CrxDownloader>().Pass(),
39 context_getter, 39 context_getter, url_fetcher_task_runner));
40 url_fetcher_task_runner));
41 #if defined(OS_WIN) 40 #if defined(OS_WIN)
42 if (is_background_download) { 41 if (is_background_download) {
43 return new BackgroundDownloader( 42 return new BackgroundDownloader(url_fetcher_downloader.Pass(),
44 url_fetcher_downloader.Pass(), context_getter, background_task_runner); 43 context_getter, background_task_runner);
45 } 44 }
46 #endif 45 #endif
47 46
48 return url_fetcher_downloader.release(); 47 return url_fetcher_downloader.release();
49 } 48 }
50 49
51 CrxDownloader::CrxDownloader(scoped_ptr<CrxDownloader> successor) 50 CrxDownloader::CrxDownloader(scoped_ptr<CrxDownloader> successor)
52 : successor_(successor.Pass()) { 51 : successor_(successor.Pass()) {
53 } 52 }
54 53
55 CrxDownloader::~CrxDownloader() { 54 CrxDownloader::~CrxDownloader() {
56 } 55 }
57 56
58 void CrxDownloader::set_progress_callback( 57 void CrxDownloader::set_progress_callback(
59 const ProgressCallback& progress_callback) { 58 const ProgressCallback& progress_callback) {
60 progress_callback_ = progress_callback; 59 progress_callback_ = progress_callback;
61 } 60 }
62 61
63 GURL CrxDownloader::url() const { 62 GURL CrxDownloader::url() const {
64 return current_url_ != urls_.end() ? *current_url_ : GURL(); 63 return current_url_ != urls_.end() ? *current_url_ : GURL();
65 } 64 }
66 65
67 const std::vector<CrxDownloader::DownloadMetrics> 66 const std::vector<CrxDownloader::DownloadMetrics>
68 CrxDownloader::download_metrics() const { 67 CrxDownloader::download_metrics() const {
69 if (!successor_) 68 if (!successor_)
70 return download_metrics_; 69 return download_metrics_;
71 70
72 std::vector<DownloadMetrics> retval(successor_->download_metrics()); 71 std::vector<DownloadMetrics> retval(successor_->download_metrics());
73 retval.insert( 72 retval.insert(retval.begin(), download_metrics_.begin(),
74 retval.begin(), download_metrics_.begin(), download_metrics_.end()); 73 download_metrics_.end());
75 return retval; 74 return retval;
76 } 75 }
77 76
78 void CrxDownloader::StartDownloadFromUrl( 77 void CrxDownloader::StartDownloadFromUrl(
79 const GURL& url, 78 const GURL& url,
80 const DownloadCallback& download_callback) { 79 const DownloadCallback& download_callback) {
81 std::vector<GURL> urls; 80 std::vector<GURL> urls;
82 urls.push_back(url); 81 urls.push_back(url);
83 StartDownload(urls, download_callback); 82 StartDownload(urls, download_callback);
84 } 83 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 147
149 void CrxDownloader::OnDownloadProgress(const Result& result) { 148 void CrxDownloader::OnDownloadProgress(const Result& result) {
150 DCHECK(thread_checker_.CalledOnValidThread()); 149 DCHECK(thread_checker_.CalledOnValidThread());
151 150
152 if (progress_callback_.is_null()) 151 if (progress_callback_.is_null())
153 return; 152 return;
154 153
155 progress_callback_.Run(result); 154 progress_callback_.Run(result);
156 } 155 }
157 156
158 } // namespace component_updater 157 } // namespace update_client
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698