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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "chrome/browser/component_updater/crx_downloader.h"
13 #include "net/url_request/url_fetcher_delegate.h"
17 class URLRequestContextGetter
;
20 namespace component_updater
{
22 // Implements a CRX downloader in top of the URLFetcher.
23 class UrlFetcherDownloader
: public CrxDownloader
,
24 public net::URLFetcherDelegate
{
26 friend class CrxDownloader
;
27 UrlFetcherDownloader(scoped_ptr
<CrxDownloader
> successor
,
28 net::URLRequestContextGetter
* context_getter
,
29 scoped_refptr
<base::SequencedTaskRunner
> task_runner
,
30 const DownloadCallback
& download_callback
);
31 virtual ~UrlFetcherDownloader();
34 // Overrides for CrxDownloader.
35 virtual void DoStartDownload(const GURL
& url
) OVERRIDE
;
37 // Overrides for URLFetcherDelegate.
38 virtual void OnURLFetchComplete(const net::URLFetcher
* source
) OVERRIDE
;
39 virtual void OnURLFetchDownloadProgress(const net::URLFetcher
* source
,
41 int64 total
) OVERRIDE
;
42 scoped_ptr
<net::URLFetcher
> url_fetcher_
;
43 net::URLRequestContextGetter
* context_getter_
;
44 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
46 base::Time download_start_time_
;
48 int64 downloaded_bytes_
;
51 DISALLOW_COPY_AND_ASSIGN(UrlFetcherDownloader
);
54 } // namespace component_updater
56 #endif // CHROME_BROWSER_COMPONENT_UPDATER_URL_FETCHER_DOWNLOADER_H_