| 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/crx_downloader.h" | 5 #include "components/update_client/crx_downloader.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/location.h" | 10 #include "base/location.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 13 #include "components/update_client/url_fetcher_downloader.h" | 15 #include "components/update_client/url_fetcher_downloader.h" |
| 14 | 16 |
| 15 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 16 #include "components/update_client/background_downloader_win.h" | 18 #include "components/update_client/background_downloader_win.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 } | 33 } |
| 32 | 34 |
| 33 // On Windows, the first downloader in the chain is a background downloader, | 35 // On Windows, the first downloader in the chain is a background downloader, |
| 34 // which uses the BITS service. | 36 // which uses the BITS service. |
| 35 scoped_ptr<CrxDownloader> CrxDownloader::Create( | 37 scoped_ptr<CrxDownloader> CrxDownloader::Create( |
| 36 bool is_background_download, | 38 bool is_background_download, |
| 37 net::URLRequestContextGetter* context_getter, | 39 net::URLRequestContextGetter* context_getter, |
| 38 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 40 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| 39 scoped_ptr<CrxDownloader> url_fetcher_downloader( | 41 scoped_ptr<CrxDownloader> url_fetcher_downloader( |
| 40 scoped_ptr<CrxDownloader>(new UrlFetcherDownloader( | 42 scoped_ptr<CrxDownloader>(new UrlFetcherDownloader( |
| 41 scoped_ptr<CrxDownloader>().Pass(), context_getter, task_runner))); | 43 scoped_ptr<CrxDownloader>(), context_getter, task_runner))); |
| 42 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 43 if (is_background_download) { | 45 if (is_background_download) { |
| 44 return scoped_ptr<CrxDownloader>(new BackgroundDownloader( | 46 return scoped_ptr<CrxDownloader>(new BackgroundDownloader( |
| 45 url_fetcher_downloader.Pass(), context_getter, task_runner)); | 47 url_fetcher_downloader.Pass(), context_getter, task_runner)); |
| 46 } | 48 } |
| 47 #endif | 49 #endif |
| 48 | 50 |
| 49 return url_fetcher_downloader; | 51 return url_fetcher_downloader; |
| 50 } | 52 } |
| 51 | 53 |
| 52 CrxDownloader::CrxDownloader(scoped_ptr<CrxDownloader> successor) | 54 CrxDownloader::CrxDownloader(scoped_ptr<CrxDownloader> successor) |
| 53 : successor_(successor.Pass()) { | 55 : successor_(std::move(successor)) {} |
| 54 } | |
| 55 | 56 |
| 56 CrxDownloader::~CrxDownloader() { | 57 CrxDownloader::~CrxDownloader() { |
| 57 } | 58 } |
| 58 | 59 |
| 59 void CrxDownloader::set_progress_callback( | 60 void CrxDownloader::set_progress_callback( |
| 60 const ProgressCallback& progress_callback) { | 61 const ProgressCallback& progress_callback) { |
| 61 progress_callback_ = progress_callback; | 62 progress_callback_ = progress_callback; |
| 62 } | 63 } |
| 63 | 64 |
| 64 GURL CrxDownloader::url() const { | 65 GURL CrxDownloader::url() const { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 void CrxDownloader::OnDownloadProgress(const Result& result) { | 152 void CrxDownloader::OnDownloadProgress(const Result& result) { |
| 152 DCHECK(thread_checker_.CalledOnValidThread()); | 153 DCHECK(thread_checker_.CalledOnValidThread()); |
| 153 | 154 |
| 154 if (progress_callback_.is_null()) | 155 if (progress_callback_.is_null()) |
| 155 return; | 156 return; |
| 156 | 157 |
| 157 progress_callback_.Run(result); | 158 progress_callback_.Run(result); |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace update_client | 161 } // namespace update_client |
| OLD | NEW |