OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ |
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 17 matching lines...) Expand all Loading... |
28 // be piped into a SplitFileWriter, which will direct it to the kernel | 28 // be piped into a SplitFileWriter, which will direct it to the kernel |
29 // and rootfs partitions. If it's a delta update, the destination kernel | 29 // and rootfs partitions. If it's a delta update, the destination kernel |
30 // and rootfs should already contain the source-version that this delta | 30 // and rootfs should already contain the source-version that this delta |
31 // update goes from. In this case, the update will be piped into a | 31 // update goes from. In this case, the update will be piped into a |
32 // DeltaPerformer that will apply the delta to the disk. | 32 // DeltaPerformer that will apply the delta to the disk. |
33 | 33 |
34 namespace chromeos_update_engine { | 34 namespace chromeos_update_engine { |
35 | 35 |
36 class DownloadActionDelegate { | 36 class DownloadActionDelegate { |
37 public: | 37 public: |
38 // Called before any bytes are received and periodically after | 38 // Called right before starting the download with |active| set to |
39 // bytes are received. | 39 // true. Called after completing the download with |active| set to |
40 // bytes_received is the number of bytes downloaded thus far. | 40 // false. |
41 // total is the number of bytes expected. | 41 virtual void SetDownloadStatus(bool active) = 0; |
| 42 |
| 43 // Called periodically after bytes are received. This method will be |
| 44 // invoked only if the download is active. |bytes_received| is the |
| 45 // number of bytes downloaded thus far. |total| is the number of |
| 46 // bytes expected. |
42 virtual void BytesReceived(uint64_t bytes_received, uint64_t total) = 0; | 47 virtual void BytesReceived(uint64_t bytes_received, uint64_t total) = 0; |
43 }; | 48 }; |
44 | 49 |
45 class DownloadAction; | 50 class DownloadAction; |
46 class NoneType; | 51 class NoneType; |
47 | 52 |
48 template<> | 53 template<> |
49 class ActionTraits<DownloadAction> { | 54 class ActionTraits<DownloadAction> { |
50 public: | 55 public: |
51 // Takes and returns an InstallPlan | 56 // Takes and returns an InstallPlan |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 scoped_ptr<DirectFileWriter> rootfs_file_writer_; | 104 scoped_ptr<DirectFileWriter> rootfs_file_writer_; |
100 | 105 |
101 // Used to apply a delta update: | 106 // Used to apply a delta update: |
102 scoped_ptr<DeltaPerformer> delta_performer_; | 107 scoped_ptr<DeltaPerformer> delta_performer_; |
103 | 108 |
104 // Pointer to the HttpFetcher that does the http work. | 109 // Pointer to the HttpFetcher that does the http work. |
105 scoped_ptr<HttpFetcher> http_fetcher_; | 110 scoped_ptr<HttpFetcher> http_fetcher_; |
106 | 111 |
107 // Used to find the hash of the bytes downloaded | 112 // Used to find the hash of the bytes downloaded |
108 OmahaHashCalculator omaha_hash_calculator_; | 113 OmahaHashCalculator omaha_hash_calculator_; |
109 | 114 |
110 // For reporting status to outsiders | 115 // For reporting status to outsiders |
111 DownloadActionDelegate* delegate_; | 116 DownloadActionDelegate* delegate_; |
112 uint64_t bytes_received_; | 117 uint64_t bytes_received_; |
113 | 118 |
114 DISALLOW_COPY_AND_ASSIGN(DownloadAction); | 119 DISALLOW_COPY_AND_ASSIGN(DownloadAction); |
115 }; | 120 }; |
116 | 121 |
117 // We want to be sure that we're compiled with large file support on linux, | 122 // We want to be sure that we're compiled with large file support on linux, |
118 // just in case we find ourselves downloading large images. | 123 // just in case we find ourselves downloading large images. |
119 COMPILE_ASSERT(8 == sizeof(off_t), off_t_not_64_bit); | 124 COMPILE_ASSERT(8 == sizeof(off_t), off_t_not_64_bit); |
120 | 125 |
121 } // namespace chromeos_update_engine | 126 } // namespace chromeos_update_engine |
122 | 127 |
123 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ | 128 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ |
OLD | NEW |