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_CRX_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // chain of responsibility. |is_background_download| specifies that a | 75 // chain of responsibility. |is_background_download| specifies that a |
76 // background downloader be used, if the platform supports it. | 76 // background downloader be used, if the platform supports it. |
77 static CrxDownloader* Create( | 77 static CrxDownloader* Create( |
78 bool is_background_download, | 78 bool is_background_download, |
79 net::URLRequestContextGetter* context_getter, | 79 net::URLRequestContextGetter* context_getter, |
80 scoped_refptr<base::SequencedTaskRunner> task_runner, | 80 scoped_refptr<base::SequencedTaskRunner> task_runner, |
81 const DownloadCallback& download_callback); | 81 const DownloadCallback& download_callback); |
82 virtual ~CrxDownloader(); | 82 virtual ~CrxDownloader(); |
83 | 83 |
84 // Starts the download. One instance of the class handles one download only. | 84 // Starts the download. One instance of the class handles one download only. |
85 // Returns true if success or false in case of errors. One instance of | 85 // One instance of CrxDownloader can only be started once, otherwise the |
86 // CrxDownloader can only be started once, otherwise the behavior is | 86 // behavior is undefined. The callback gets invoked if the download can't |
87 // undefined. | 87 // be started. |
88 bool StartDownloadFromUrl(const GURL& url); | 88 void StartDownloadFromUrl(const GURL& url); |
89 bool StartDownload(const std::vector<GURL>& urls); | 89 void StartDownload(const std::vector<GURL>& urls); |
90 | 90 |
91 const std::vector<DownloadMetrics> download_metrics() const; | 91 const std::vector<DownloadMetrics> download_metrics() const; |
92 | 92 |
93 protected: | 93 protected: |
94 CrxDownloader(scoped_ptr<CrxDownloader> successor, | 94 CrxDownloader(scoped_ptr<CrxDownloader> successor, |
95 const DownloadCallback& download_callback); | 95 const DownloadCallback& download_callback); |
96 | 96 |
97 // Handles the fallback in the case of multiple urls and routing of the | 97 // Handles the fallback in the case of multiple urls and routing of the |
98 // download to the following successor in the chain. Derived classes must call | 98 // download to the following successor in the chain. Derived classes must call |
99 // this function after each attempt at downloading the urls provided | 99 // this function after each attempt at downloading the urls provided |
(...skipping 20 matching lines...) Expand all Loading... |
120 | 120 |
121 std::vector<DownloadMetrics> download_metrics_; | 121 std::vector<DownloadMetrics> download_metrics_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(CrxDownloader); | 123 DISALLOW_COPY_AND_ASSIGN(CrxDownloader); |
124 }; | 124 }; |
125 | 125 |
126 } // namespace component_updater | 126 } // namespace component_updater |
127 | 127 |
128 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ | 128 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ |
129 | 129 |
OLD | NEW |