| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "chrome/browser/component_updater/crx_downloader.h" | 12 #include "chrome/browser/component_updater/crx_downloader.h" |
| 13 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 class URLFetcher; | 16 class URLFetcher; |
| 17 class URLRequestContextGetter; | 17 class URLRequestContextGetter; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace component_updater { | 20 namespace component_updater { |
| 21 | 21 |
| 22 // Implements a CRX downloader in top of the URLFetcher. | 22 // Implements a CRX downloader in top of the URLFetcher. |
| 23 class UrlFetcherDownloader : public CrxDownloader, | 23 class UrlFetcherDownloader : public CrxDownloader, |
| 24 public net::URLFetcherDelegate { | 24 public net::URLFetcherDelegate { |
| 25 protected: | 25 protected: |
| 26 friend class CrxDownloader; | 26 friend class CrxDownloader; |
| 27 UrlFetcherDownloader(scoped_ptr<CrxDownloader> successor, | 27 UrlFetcherDownloader(scoped_ptr<CrxDownloader> successor, |
| 28 net::URLRequestContextGetter* context_getter, | 28 net::URLRequestContextGetter* context_getter, |
| 29 scoped_refptr<base::SequencedTaskRunner> task_runner, | 29 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 30 const DownloadCallback& download_callback); | |
| 31 virtual ~UrlFetcherDownloader(); | 30 virtual ~UrlFetcherDownloader(); |
| 32 | 31 |
| 33 private: | 32 private: |
| 34 // Overrides for CrxDownloader. | 33 // Overrides for CrxDownloader. |
| 35 virtual void DoStartDownload(const GURL& url) OVERRIDE; | 34 virtual void DoStartDownload(const GURL& url) OVERRIDE; |
| 36 | 35 |
| 37 // Overrides for URLFetcherDelegate. | 36 // Overrides for URLFetcherDelegate. |
| 38 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 37 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 39 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, | 38 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, |
| 40 int64 current, | 39 int64 current, |
| 41 int64 total) OVERRIDE; | 40 int64 total) OVERRIDE; |
| 42 scoped_ptr<net::URLFetcher> url_fetcher_; | 41 scoped_ptr<net::URLFetcher> url_fetcher_; |
| 43 net::URLRequestContextGetter* context_getter_; | 42 net::URLRequestContextGetter* context_getter_; |
| 44 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 43 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 45 | 44 |
| 46 base::Time download_start_time_; | 45 base::Time download_start_time_; |
| 47 | 46 |
| 48 int64 downloaded_bytes_; | 47 int64 downloaded_bytes_; |
| 49 int64 total_bytes_; | 48 int64 total_bytes_; |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(UrlFetcherDownloader); | 50 DISALLOW_COPY_AND_ASSIGN(UrlFetcherDownloader); |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 } // namespace component_updater | 53 } // namespace component_updater |
| 55 | 54 |
| 56 #endif // CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_ | 55 #endif // CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_ |
| 57 | 56 |
| OLD | NEW |