| 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 #ifndef COMPONENTS_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ | 5 #ifndef COMPONENTS_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ |
| 6 #define COMPONENTS_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 20 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 21 } | 22 } |
| 22 | 23 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 42 enum Downloader { kNone = 0, kUrlFetcher, kBits }; | 43 enum Downloader { kNone = 0, kUrlFetcher, kBits }; |
| 43 | 44 |
| 44 DownloadMetrics(); | 45 DownloadMetrics(); |
| 45 | 46 |
| 46 GURL url; | 47 GURL url; |
| 47 | 48 |
| 48 Downloader downloader; | 49 Downloader downloader; |
| 49 | 50 |
| 50 int error; | 51 int error; |
| 51 | 52 |
| 52 int64 downloaded_bytes; // -1 means that the byte count is unknown. | 53 int64_t downloaded_bytes; // -1 means that the byte count is unknown. |
| 53 int64 total_bytes; | 54 int64_t total_bytes; |
| 54 | 55 |
| 55 uint64 download_time_ms; | 56 uint64_t download_time_ms; |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 // Contains the progress or the outcome of the download. | 59 // Contains the progress or the outcome of the download. |
| 59 struct Result { | 60 struct Result { |
| 60 Result(); | 61 Result(); |
| 61 | 62 |
| 62 // Download error: 0 indicates success. | 63 // Download error: 0 indicates success. |
| 63 int error; | 64 int error; |
| 64 | 65 |
| 65 // Path of the downloaded file if the download was successful. | 66 // Path of the downloaded file if the download was successful. |
| 66 base::FilePath response; | 67 base::FilePath response; |
| 67 | 68 |
| 68 // Number of bytes actually downloaded, not including the bytes downloaded | 69 // Number of bytes actually downloaded, not including the bytes downloaded |
| 69 // as a result of falling back on urls. | 70 // as a result of falling back on urls. |
| 70 int64 downloaded_bytes; | 71 int64_t downloaded_bytes; |
| 71 | 72 |
| 72 // Number of bytes expected to be downloaded. | 73 // Number of bytes expected to be downloaded. |
| 73 int64 total_bytes; | 74 int64_t total_bytes; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 // The callback fires only once, regardless of how many urls are tried, and | 77 // The callback fires only once, regardless of how many urls are tried, and |
| 77 // how many successors in the chain of downloaders have handled the | 78 // how many successors in the chain of downloaders have handled the |
| 78 // download. The callback interface can be extended if needed to provide | 79 // download. The callback interface can be extended if needed to provide |
| 79 // more visibility into how the download has been handled, including | 80 // more visibility into how the download has been handled, including |
| 80 // specific error codes and download metrics. | 81 // specific error codes and download metrics. |
| 81 typedef base::Callback<void(const Result& result)> DownloadCallback; | 82 typedef base::Callback<void(const Result& result)> DownloadCallback; |
| 82 | 83 |
| 83 // The callback may fire 0 or many times during a download. Since this | 84 // The callback may fire 0 or many times during a download. Since this |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::vector<GURL>::iterator current_url_; | 147 std::vector<GURL>::iterator current_url_; |
| 147 | 148 |
| 148 std::vector<DownloadMetrics> download_metrics_; | 149 std::vector<DownloadMetrics> download_metrics_; |
| 149 | 150 |
| 150 DISALLOW_COPY_AND_ASSIGN(CrxDownloader); | 151 DISALLOW_COPY_AND_ASSIGN(CrxDownloader); |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace component_updater | 154 } // namespace component_updater |
| 154 | 155 |
| 155 #endif // COMPONENTS_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ | 156 #endif // COMPONENTS_COMPONENT_UPDATER_CRX_DOWNLOADER_H_ |
| OLD | NEW |