blob: 57bad26b55f9001d3ffb119e218c36a4846ebed9 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2010 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070016
Alex Deymo39910dc2015-11-09 17:04:30 -080017#ifndef UPDATE_ENGINE_PAYLOAD_CONSUMER_DELTA_PERFORMER_H_
18#define UPDATE_ENGINE_PAYLOAD_CONSUMER_DELTA_PERFORMER_H_
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070019
20#include <inttypes.h>
Darin Petkovd7061ab2010-10-06 14:37:09 -070021
Amin Hassanidb56be92017-09-06 12:41:23 -070022#include <limits>
Alex Vakulenkod2779df2014-06-16 13:19:00 -070023#include <string>
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070024#include <vector>
Darin Petkovd7061ab2010-10-06 14:37:09 -070025
Alex Vakulenko75039d72014-03-25 12:36:28 -070026#include <base/time/time.h>
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070027#include <brillo/secure_blob.h>
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070028#include <google/protobuf/repeated_field.h>
Andrew de los Reyes353777c2010-10-08 10:34:30 -070029#include <gtest/gtest_prod.h> // for FRIEND_TEST
Darin Petkovd7061ab2010-10-06 14:37:09 -070030
Alex Deymo39910dc2015-11-09 17:04:30 -080031#include "update_engine/common/hash_calculator.h"
32#include "update_engine/common/platform_constants.h"
33#include "update_engine/payload_consumer/file_descriptor.h"
34#include "update_engine/payload_consumer/file_writer.h"
35#include "update_engine/payload_consumer/install_plan.h"
Sen Jiangb5f601d2018-02-02 13:51:21 -080036#include "update_engine/payload_consumer/payload_metadata.h"
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070037#include "update_engine/update_metadata.pb.h"
38
39namespace chromeos_update_engine {
40
Alex Deymo542c19b2015-12-03 07:43:31 -030041class DownloadActionDelegate;
42class BootControlInterface;
43class HardwareInterface;
Darin Petkov73058b42010-10-06 16:32:19 -070044class PrefsInterface;
45
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070046// This class performs the actions in a delta update synchronously. The delta
47// update itself should be passed in in chunks as it is received.
48
49class DeltaPerformer : public FileWriter {
50 public:
Gilad Arnold8a86fa52013-01-15 12:35:05 -080051 // Defines the granularity of progress logging in terms of how many "completed
52 // chunks" we want to report at the most.
53 static const unsigned kProgressLogMaxChunks;
54 // Defines a timeout since the last progress was logged after which we want to
55 // force another log message (even if the current chunk was not completed).
56 static const unsigned kProgressLogTimeoutSeconds;
57 // These define the relative weights (0-100) we give to the different work
58 // components associated with an update when computing an overall progress.
59 // Currently they include the download progress and the number of completed
60 // operations. They must add up to one hundred (100).
61 static const unsigned kProgressDownloadWeight;
62 static const unsigned kProgressOperationsWeight;
63
Jay Srinivasanf0572052012-10-23 18:12:56 -070064 DeltaPerformer(PrefsInterface* prefs,
Alex Deymo542c19b2015-12-03 07:43:31 -030065 BootControlInterface* boot_control,
66 HardwareInterface* hardware,
67 DownloadActionDelegate* download_delegate,
Sen Jiang0affc2c2017-02-10 15:55:05 -080068 InstallPlan* install_plan,
Sen Jiang18414082018-01-11 14:50:36 -080069 InstallPlan::Payload* payload,
Amin Hassanied37d682018-04-06 13:22:00 -070070 bool interactive)
Darin Petkov73058b42010-10-06 16:32:19 -070071 : prefs_(prefs),
Alex Deymo542c19b2015-12-03 07:43:31 -030072 boot_control_(boot_control),
73 hardware_(hardware),
74 download_delegate_(download_delegate),
Sen Jiang0affc2c2017-02-10 15:55:05 -080075 install_plan_(install_plan),
Sen Jiang18414082018-01-11 14:50:36 -080076 payload_(payload),
Amin Hassanied37d682018-04-06 13:22:00 -070077 interactive_(interactive) {}
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070078
Jay Srinivasan51dcf262012-09-13 17:24:32 -070079 // FileWriter's Write implementation where caller doesn't care about
80 // error codes.
Alex Deymo610277e2014-11-11 21:18:11 -080081 bool Write(const void* bytes, size_t count) override {
David Zeuthena99981f2013-04-29 13:42:47 -070082 ErrorCode error;
Jay Srinivasan51dcf262012-09-13 17:24:32 -070083 return Write(bytes, count, &error);
84 }
85
86 // FileWriter's Write implementation that returns a more specific |error| code
87 // in case of failures in Write operation.
Alex Deymo610277e2014-11-11 21:18:11 -080088 bool Write(const void* bytes, size_t count, ErrorCode *error) override;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070089
90 // Wrapper around close. Returns 0 on success or -errno on error.
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -070091 // Closes both 'path' given to Open() and the kernel path.
Alex Deymo610277e2014-11-11 21:18:11 -080092 int Close() override;
Darin Petkovd7061ab2010-10-06 14:37:09 -070093
Alex Deymoe5e5fe92015-10-05 09:28:19 -070094 // Open the target and source (if delta payload) file descriptors for the
95 // |current_partition_|. The manifest needs to be already parsed for this to
96 // work. Returns whether the required file descriptors were successfully open.
97 bool OpenCurrentPartition();
98
Alex Deymo51c264e2016-11-04 15:49:53 -070099 // Attempt to open the error-corrected device for the current partition.
100 // Returns whether the operation succeeded.
101 bool OpenCurrentECCPartition();
102
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700103 // Closes the current partition file descriptors if open. Returns 0 on success
104 // or -errno on error.
105 int CloseCurrentPartition();
106
David Zeuthen8f191b22013-08-06 12:27:50 -0700107 // Returns |true| only if the manifest has been processed and it's valid.
108 bool IsManifestValid();
109
Darin Petkovd7061ab2010-10-06 14:37:09 -0700110 // Verifies the downloaded payload against the signed hash included in the
Sen Jiang2703ef42017-03-16 13:36:21 -0700111 // payload, against the update check hash and size using the public key and
112 // returns ErrorCode::kSuccess on success, an error code on failure.
113 // This method should be called after closing the stream. Note this method
114 // skips the signed hash check if the public key is unavailable; it returns
115 // ErrorCode::kSignedDeltaPayloadExpectedError if the public key is available
116 // but the delta payload doesn't include a signature.
117 ErrorCode VerifyPayload(const brillo::Blob& update_check_response_hash,
Allie Wood9f6f0a52015-03-30 11:25:47 -0700118 const uint64_t update_check_response_size);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700119
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700120 // Converts an ordered collection of Extent objects which contain data of
121 // length full_length to a comma-separated string. For each Extent, the
122 // string will have the start offset and then the length in bytes.
123 // The length value of the last extent in the string may be short, since
124 // the full length of all extents in the string is capped to full_length.
125 // Also, an extent starting at kSparseHole, appears as -1 in the string.
126 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1},
127 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13,
128 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
129 static bool ExtentsToBsdiffPositionsString(
130 const google::protobuf::RepeatedPtrField<Extent>& extents,
131 uint64_t block_size,
132 uint64_t full_length,
133 std::string* positions_string);
134
Darin Petkov0406e402010-10-06 21:33:11 -0700135 // Returns true if a previous update attempt can be continued based on the
136 // persistent preferences and the new update check response hash.
137 static bool CanResumeUpdate(PrefsInterface* prefs,
Chih-Hung Hsieh5c6bb1d2016-07-27 13:33:15 -0700138 const std::string& update_check_response_hash);
Darin Petkov0406e402010-10-06 21:33:11 -0700139
140 // Resets the persistent update progress state to indicate that an update
Darin Petkov9b230572010-10-08 10:20:09 -0700141 // can't be resumed. Performs a quick update-in-progress reset if |quick| is
142 // true, otherwise resets all progress-related update state. Returns true on
143 // success, false otherwise.
144 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick);
Darin Petkov0406e402010-10-06 21:33:11 -0700145
Darin Petkov9574f7e2011-01-13 10:48:12 -0800146 // Attempts to parse the update metadata starting from the beginning of
Gilad Arnolddaa27402014-01-23 11:56:17 -0800147 // |payload|. On success, returns kMetadataParseSuccess. Returns
Gilad Arnoldfe133932014-01-14 12:25:50 -0800148 // kMetadataParseInsufficientData if more data is needed to parse the complete
149 // metadata. Returns kMetadataParseError if the metadata can't be parsed given
150 // the payload.
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -0700151 MetadataParseResult ParsePayloadMetadata(const brillo::Blob& payload,
Gilad Arnolddaa27402014-01-23 11:56:17 -0800152 ErrorCode* error);
Darin Petkov9574f7e2011-01-13 10:48:12 -0800153
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700154 void set_public_key_path(const std::string& public_key_path) {
155 public_key_path_ = public_key_path;
Darin Petkov698d0412010-10-13 10:59:44 -0700156 }
157
Sen Jiangb8060e42015-09-24 17:30:50 -0700158 // Return true if header parsing is finished and no errors occurred.
159 bool IsHeaderParsed() const;
160
Allie Woodfdf00512015-03-02 13:34:55 -0800161 // Returns the delta minor version. If this value is defined in the manifest,
162 // it returns that value, otherwise it returns the default value.
163 uint32_t GetMinorVersion() const;
164
Sen Jiang28d8ed92018-02-01 13:46:39 -0800165 // Compare |calculated_hash| with source hash in |operation|, return false and
166 // dump hash and set |error| if don't match.
167 // |source_fd| is the file descriptor of the source partition.
168 static bool ValidateSourceHash(const brillo::Blob& calculated_hash,
169 const InstallOperation& operation,
170 const FileDescriptorPtr source_fd,
171 ErrorCode* error);
172
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700173 private:
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700174 friend class DeltaPerformerTest;
Sen Jianga4365d62015-09-25 10:52:25 -0700175 friend class DeltaPerformerIntegrationTest;
Sen Jiang76bfa742015-10-12 17:13:26 -0700176 FRIEND_TEST(DeltaPerformerTest, BrilloMetadataSignatureSizeTest);
Sen Jiangb5f601d2018-02-02 13:51:21 -0800177 FRIEND_TEST(DeltaPerformerTest, BrilloParsePayloadMetadataTest);
David Zeuthene7f89172013-10-31 10:21:04 -0700178 FRIEND_TEST(DeltaPerformerTest, UsePublicKeyFromResponse);
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700179
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700180 // Parse and move the update instructions of all partitions into our local
181 // |partitions_| variable based on the version of the payload. Requires the
182 // manifest to be parsed and valid.
183 bool ParseManifestPartitions(ErrorCode* error);
184
Gilad Arnoldfe133932014-01-14 12:25:50 -0800185 // Appends up to |*count_p| bytes from |*bytes_p| to |buffer_|, but only to
186 // the extent that the size of |buffer_| does not exceed |max|. Advances
187 // |*cbytes_p| and decreases |*count_p| by the actual number of bytes copied,
188 // and returns this number.
189 size_t CopyDataToBuffer(const char** bytes_p, size_t* count_p, size_t max);
190
191 // If |op_result| is false, emits an error message using |op_type_name| and
192 // sets |*error| accordingly. Otherwise does nothing. Returns |op_result|.
193 bool HandleOpResult(bool op_result, const char* op_type_name,
194 ErrorCode* error);
195
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800196 // Logs the progress of downloading/applying an update.
197 void LogProgress(const char* message_prefix);
198
199 // Update overall progress metrics, log as necessary.
200 void UpdateOverallProgress(bool force_log, const char* message_prefix);
201
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700202 // Returns true if enough of the delta file has been passed via Write()
203 // to be able to perform a given install operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700204 bool CanPerformInstallOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700205
Gilad Arnold21504f02013-05-24 08:51:22 -0700206 // Checks the integrity of the payload manifest. Returns true upon success,
207 // false otherwise.
208 ErrorCode ValidateManifest();
209
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700210 // Validates that the hash of the blobs corresponding to the given |operation|
211 // matches what's specified in the manifest in the payload.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700212 // Returns ErrorCode::kSuccess on match or a suitable error code otherwise.
Alex Deymoa12ee112015-08-12 22:19:32 -0700213 ErrorCode ValidateOperationHash(const InstallOperation& operation);
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700214
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700215 // Returns true on success.
Alex Deymoa12ee112015-08-12 22:19:32 -0700216 bool PerformInstallOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700217
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700218 // These perform a specific type of operation and return true on success.
Sen Jiangbe2c47b2016-06-15 14:09:27 -0700219 // |error| will be set if source hash mismatch, otherwise |error| might not be
220 // set even if it fails.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700221 bool PerformReplaceOperation(const InstallOperation& operation);
222 bool PerformZeroOrDiscardOperation(const InstallOperation& operation);
223 bool PerformMoveOperation(const InstallOperation& operation);
224 bool PerformBsdiffOperation(const InstallOperation& operation);
Sen Jiangbe2c47b2016-06-15 14:09:27 -0700225 bool PerformSourceCopyOperation(const InstallOperation& operation,
226 ErrorCode* error);
227 bool PerformSourceBsdiffOperation(const InstallOperation& operation,
228 ErrorCode* error);
Amin Hassani02855c22017-09-06 22:34:50 -0700229 bool PerformPuffDiffOperation(const InstallOperation& operation,
230 ErrorCode* error);
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700231
Sen Jiangf6813802015-11-03 21:27:29 -0800232 // Extracts the payload signature message from the blob on the |operation| if
233 // the offset matches the one specified by the manifest. Returns whether the
234 // signature was extracted.
235 bool ExtractSignatureMessageFromOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700236
Sen Jiangf6813802015-11-03 21:27:29 -0800237 // Extracts the payload signature message from the current |buffer_| if the
238 // offset matches the one specified by the manifest. Returns whether the
239 // signature was extracted.
240 bool ExtractSignatureMessage();
241
242 // Updates the payload hash calculator with the bytes in |buffer_|, also
243 // updates the signed hash calculator with the first |signed_hash_buffer_size|
244 // bytes in |buffer_|. Then discard the content, ensuring that memory is being
245 // deallocated. If |do_advance_offset|, advances the internal offset counter
246 // accordingly.
247 void DiscardBuffer(bool do_advance_offset, size_t signed_hash_buffer_size);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700248
Darin Petkov0406e402010-10-06 21:33:11 -0700249 // Checkpoints the update progress into persistent storage to allow this
250 // update attempt to be resumed after reboot.
Darin Petkov73058b42010-10-06 16:32:19 -0700251 bool CheckpointUpdateProgress();
252
Darin Petkov9b230572010-10-08 10:20:09 -0700253 // Primes the required update state. Returns true if the update state was
254 // successfully initialized to a saved resume state or if the update is a new
255 // update. Returns false otherwise.
256 bool PrimeUpdateState();
257
David Zeuthene7f89172013-10-31 10:21:04 -0700258 // If the Omaha response contains a public RSA key and we're allowed
259 // to use it (e.g. if we're in developer mode), extract the key from
260 // the response and store it in a temporary file and return true. In
261 // the affirmative the path to the temporary file is stored in
262 // |out_tmp_key| and it is the responsibility of the caller to clean
263 // it up.
264 bool GetPublicKeyFromResponse(base::FilePath *out_tmp_key);
265
Darin Petkov73058b42010-10-06 16:32:19 -0700266 // Update Engine preference store.
267 PrefsInterface* prefs_;
268
Alex Deymo542c19b2015-12-03 07:43:31 -0300269 // BootControl and Hardware interface references.
270 BootControlInterface* boot_control_;
271 HardwareInterface* hardware_;
272
273 // The DownloadActionDelegate instance monitoring the DownloadAction, or a
274 // nullptr if not used.
275 DownloadActionDelegate* download_delegate_;
Jay Srinivasanf0572052012-10-23 18:12:56 -0700276
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700277 // Install Plan based on Omaha Response.
278 InstallPlan* install_plan_;
279
Sen Jiang0affc2c2017-02-10 15:55:05 -0800280 // Pointer to the current payload in install_plan_.payloads.
281 InstallPlan::Payload* payload_{nullptr};
282
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700283 // File descriptor of the source partition. Only set while updating a
284 // partition when using a delta payload.
285 FileDescriptorPtr source_fd_{nullptr};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700286
Alex Deymo51c264e2016-11-04 15:49:53 -0700287 // File descriptor of the error corrected source partition. Only set while
288 // updating partition using a delta payload for a partition where error
289 // correction is available. The size of the error corrected device is smaller
290 // than the underlying raw device, since it doesn't include the error
291 // correction blocks.
292 FileDescriptorPtr source_ecc_fd_{nullptr};
293
294 // The total number of operations that failed source hash verification but
295 // passed after falling back to the error-corrected |source_ecc_fd_| device.
296 uint64_t source_ecc_recovered_failures_{0};
297
298 // Whether opening the current partition as an error-corrected device failed.
299 // Used to avoid re-opening the same source partition if it is not actually
300 // error corrected.
301 bool source_ecc_open_failure_{false};
302
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700303 // File descriptor of the target partition. Only set while performing the
304 // operations of a given partition.
305 FileDescriptorPtr target_fd_{nullptr};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700306
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700307 // Paths the |source_fd_| and |target_fd_| refer to.
308 std::string source_path_;
309 std::string target_path_;
Allie Woodfdf00512015-03-02 13:34:55 -0800310
Sen Jiangb5f601d2018-02-02 13:51:21 -0800311 PayloadMetadata payload_metadata_;
312
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700313 // Parsed manifest. Set after enough bytes to parse the manifest were
314 // downloaded.
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700315 DeltaArchiveManifest manifest_;
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700316 bool manifest_parsed_{false};
317 bool manifest_valid_{false};
318 uint64_t metadata_size_{0};
Sen Jiang76bfa742015-10-12 17:13:26 -0700319 uint32_t metadata_signature_size_{0};
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700320 uint64_t major_payload_version_{0};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700321
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700322 // Accumulated number of operations per partition. The i-th element is the
323 // sum of the number of operations for all the partitions from 0 to i
324 // inclusive. Valid when |manifest_valid_| is true.
325 std::vector<size_t> acc_num_operations_;
326
327 // The total operations in a payload. Valid when |manifest_valid_| is true,
328 // otherwise 0.
329 size_t num_total_operations_{0};
330
331 // The list of partitions to update as found in the manifest major version 2.
332 // When parsing an older manifest format, the information is converted over to
333 // this format instead.
334 std::vector<PartitionUpdate> partitions_;
335
336 // Index in the list of partitions (|partitions_| member) of the current
337 // partition being processed.
338 size_t current_partition_{0};
339
340 // Index of the next operation to perform in the manifest. The index is linear
341 // on the total number of operation on the manifest.
342 size_t next_operation_num_{0};
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700343
Gilad Arnoldfe133932014-01-14 12:25:50 -0800344 // A buffer used for accumulating downloaded data. Initially, it stores the
345 // payload metadata; once that's downloaded and parsed, it stores data for the
346 // next update operation.
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -0700347 brillo::Blob buffer_;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700348 // Offset of buffer_ in the binary blobs section of the update.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700349 uint64_t buffer_offset_{0};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700350
Darin Petkov0406e402010-10-06 21:33:11 -0700351 // Last |buffer_offset_| value updated as part of the progress update.
Alex Vakulenko0103c362016-01-20 07:56:15 -0800352 uint64_t last_updated_buffer_offset_{std::numeric_limits<uint64_t>::max()};
Darin Petkov0406e402010-10-06 21:33:11 -0700353
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700354 // The block size (parsed from the manifest).
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700355 uint32_t block_size_{0};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700356
Sen Jiangf6813802015-11-03 21:27:29 -0800357 // Calculates the whole payload file hash, including headers and signatures.
Alex Deymo39910dc2015-11-09 17:04:30 -0800358 HashCalculator payload_hash_calculator_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700359
Sen Jiangf6813802015-11-03 21:27:29 -0800360 // Calculates the hash of the portion of the payload signed by the payload
361 // signature. This hash skips the metadata signature portion, located after
362 // the metadata and doesn't include the payload signature itself.
Alex Deymo39910dc2015-11-09 17:04:30 -0800363 HashCalculator signed_hash_calculator_;
Darin Petkov437adc42010-10-07 13:12:24 -0700364
Darin Petkovd7061ab2010-10-06 14:37:09 -0700365 // Signatures message blob extracted directly from the payload.
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -0700366 brillo::Blob signatures_message_data_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700367
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700368 // The public key to be used. Provided as a member so that tests can
369 // override with test keys.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700370 std::string public_key_path_{constants::kUpdatePayloadPublicKeyPath};
Darin Petkov698d0412010-10-13 10:59:44 -0700371
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800372 // The number of bytes received so far, used for progress tracking.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700373 size_t total_bytes_received_{0};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800374
375 // An overall progress counter, which should reflect both download progress
376 // and the ratio of applied operations. Range is 0-100.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700377 unsigned overall_progress_{0};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800378
379 // The last progress chunk recorded.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700380 unsigned last_progress_chunk_{0};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800381
Amin Hassani7ecda262017-07-11 17:10:50 -0700382 // If |true|, the update is user initiated (vs. periodic update checks).
Amin Hassanied37d682018-04-06 13:22:00 -0700383 bool interactive_{false};
Amin Hassani7ecda262017-07-11 17:10:50 -0700384
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800385 // The timeout after which we should force emitting a progress log (constant),
386 // and the actual point in time for the next forced log to be emitted.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700387 const base::TimeDelta forced_progress_log_wait_{
388 base::TimeDelta::FromSeconds(kProgressLogTimeoutSeconds)};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800389 base::Time forced_progress_log_time_;
390
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700391 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
392};
393
394} // namespace chromeos_update_engine
395
Alex Deymo39910dc2015-11-09 17:04:30 -0800396#endif // UPDATE_ENGINE_PAYLOAD_CONSUMER_DELTA_PERFORMER_H_