blob: 087c2adfac2594f7d3eeb938b0165c5c03391c38 [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
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_DELTA_PERFORMER_H_
18#define UPDATE_ENGINE_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
Alex Vakulenkod2779df2014-06-16 13:19:00 -070022#include <string>
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070023#include <vector>
Darin Petkovd7061ab2010-10-06 14:37:09 -070024
Alex Vakulenko75039d72014-03-25 12:36:28 -070025#include <base/time/time.h>
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -080026#include <chromeos/secure_blob.h>
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070027#include <google/protobuf/repeated_field.h>
Andrew de los Reyes353777c2010-10-08 10:34:30 -070028#include <gtest/gtest_prod.h> // for FRIEND_TEST
Darin Petkovd7061ab2010-10-06 14:37:09 -070029
Nam T. Nguyenf1d582e2014-12-08 15:07:17 -080030#include "update_engine/file_descriptor.h"
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070031#include "update_engine/file_writer.h"
Jay Srinivasan51dcf262012-09-13 17:24:32 -070032#include "update_engine/install_plan.h"
Darin Petkovd7061ab2010-10-06 14:37:09 -070033#include "update_engine/omaha_hash_calculator.h"
Alex Deymoe6fc8e12015-09-28 14:02:17 -070034#include "update_engine/platform_constants.h"
Jay Srinivasanf0572052012-10-23 18:12:56 -070035#include "update_engine/system_state.h"
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070036#include "update_engine/update_metadata.pb.h"
37
38namespace chromeos_update_engine {
39
Darin Petkov73058b42010-10-06 16:32:19 -070040class PrefsInterface;
41
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070042// This class performs the actions in a delta update synchronously. The delta
43// update itself should be passed in in chunks as it is received.
44
45class DeltaPerformer : public FileWriter {
46 public:
Darin Petkov9574f7e2011-01-13 10:48:12 -080047 enum MetadataParseResult {
48 kMetadataParseSuccess,
49 kMetadataParseError,
50 kMetadataParseInsufficientData,
51 };
52
Jay Srinivasanf4318702012-09-24 11:56:24 -070053 static const uint64_t kDeltaVersionSize;
54 static const uint64_t kDeltaManifestSizeSize;
Don Garrett4d039442013-10-28 18:40:06 -070055 static const uint64_t kSupportedMajorPayloadVersion;
Don Garrettb8dd1d92013-11-22 17:40:02 -080056 static const uint64_t kSupportedMinorPayloadVersion;
Darin Petkovabc7bc02011-02-23 14:39:43 -080057
Gilad Arnold8a86fa52013-01-15 12:35:05 -080058 // Defines the granularity of progress logging in terms of how many "completed
59 // chunks" we want to report at the most.
60 static const unsigned kProgressLogMaxChunks;
61 // Defines a timeout since the last progress was logged after which we want to
62 // force another log message (even if the current chunk was not completed).
63 static const unsigned kProgressLogTimeoutSeconds;
64 // These define the relative weights (0-100) we give to the different work
65 // components associated with an update when computing an overall progress.
66 // Currently they include the download progress and the number of completed
67 // operations. They must add up to one hundred (100).
68 static const unsigned kProgressDownloadWeight;
69 static const unsigned kProgressOperationsWeight;
70
Jay Srinivasanf0572052012-10-23 18:12:56 -070071 DeltaPerformer(PrefsInterface* prefs,
72 SystemState* system_state,
73 InstallPlan* install_plan)
Darin Petkov73058b42010-10-06 16:32:19 -070074 : prefs_(prefs),
Jay Srinivasanf0572052012-10-23 18:12:56 -070075 system_state_(system_state),
Jay Srinivasan51dcf262012-09-13 17:24:32 -070076 install_plan_(install_plan),
Nam T. Nguyenf1d582e2014-12-08 15:07:17 -080077 fd_(nullptr),
78 kernel_fd_(nullptr),
Allie Woodfdf00512015-03-02 13:34:55 -080079 source_fd_(nullptr),
80 source_kernel_fd_(nullptr),
Gilad Arnolddaa27402014-01-23 11:56:17 -080081 manifest_parsed_(false),
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070082 manifest_valid_(false),
Gilad Arnoldfe133932014-01-14 12:25:50 -080083 metadata_size_(0),
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -070084 next_operation_num_(0),
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070085 buffer_offset_(0),
Darin Petkov0406e402010-10-06 21:33:11 -070086 last_updated_buffer_offset_(kuint64max),
Jay Srinivasan51dcf262012-09-13 17:24:32 -070087 block_size_(0),
Alex Deymoe6fc8e12015-09-28 14:02:17 -070088 public_key_path_(constants::kUpdatePayloadPublicKeyPath),
Gilad Arnold8a86fa52013-01-15 12:35:05 -080089 total_bytes_received_(0),
90 num_rootfs_operations_(0),
91 num_total_operations_(0),
92 overall_progress_(0),
93 last_progress_chunk_(0),
94 forced_progress_log_wait_(
Allie Woodfdf00512015-03-02 13:34:55 -080095 base::TimeDelta::FromSeconds(kProgressLogTimeoutSeconds)),
96 supported_minor_version_(kSupportedMinorPayloadVersion) {}
Darin Petkovd7061ab2010-10-06 14:37:09 -070097
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -070098 // Opens the kernel. Should be called before or after Open(), but before
99 // Write(). The kernel file will be close()d when Close() is called.
100 bool OpenKernel(const char* kernel_path);
101
Allie Woodfdf00512015-03-02 13:34:55 -0800102 // Opens the source partition. The file will be closed when Close() is called.
103 bool OpenSourceRootfs(const std::string& kernel_path);
104
105 // Opens the source kernel. The file will be closed when Close() is called.
106 bool OpenSourceKernel(const std::string& source_kernel_path);
107
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700108 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be
109 // Open()ed again.
Alex Deymo610277e2014-11-11 21:18:11 -0800110 int Open(const char* path, int flags, mode_t mode) override;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700111
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700112 // FileWriter's Write implementation where caller doesn't care about
113 // error codes.
Alex Deymo610277e2014-11-11 21:18:11 -0800114 bool Write(const void* bytes, size_t count) override {
David Zeuthena99981f2013-04-29 13:42:47 -0700115 ErrorCode error;
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700116 return Write(bytes, count, &error);
117 }
118
119 // FileWriter's Write implementation that returns a more specific |error| code
120 // in case of failures in Write operation.
Alex Deymo610277e2014-11-11 21:18:11 -0800121 bool Write(const void* bytes, size_t count, ErrorCode *error) override;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700122
123 // Wrapper around close. Returns 0 on success or -errno on error.
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700124 // Closes both 'path' given to Open() and the kernel path.
Alex Deymo610277e2014-11-11 21:18:11 -0800125 int Close() override;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700126
David Zeuthen8f191b22013-08-06 12:27:50 -0700127 // Returns |true| only if the manifest has been processed and it's valid.
128 bool IsManifestValid();
129
Darin Petkovd7061ab2010-10-06 14:37:09 -0700130 // Verifies the downloaded payload against the signed hash included in the
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700131 // payload, against the update check hash (which is in base64 format) and
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700132 // size using the public key and returns ErrorCode::kSuccess on success, an
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700133 // error code on failure. This method should be called after closing the
134 // stream. Note this method skips the signed hash check if the public key is
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700135 // unavailable; it returns ErrorCode::kSignedDeltaPayloadExpectedError if the
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700136 // public key is available but the delta payload doesn't include a signature.
David Zeuthena99981f2013-04-29 13:42:47 -0700137 ErrorCode VerifyPayload(const std::string& update_check_response_hash,
Allie Wood9f6f0a52015-03-30 11:25:47 -0700138 const uint64_t update_check_response_size);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700139
Darin Petkov3aefa862010-12-07 14:45:00 -0800140 // Reads from the update manifest the expected sizes and hashes of the target
141 // kernel and rootfs partitions. These values can be used for applied update
142 // hash verification. This method must be called after the update manifest has
143 // been parsed (e.g., after closing the stream). Returns true on success, and
144 // false on failure (e.g., when the values are not present in the update
145 // manifest).
146 bool GetNewPartitionInfo(uint64_t* kernel_size,
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800147 chromeos::Blob* kernel_hash,
Darin Petkov3aefa862010-12-07 14:45:00 -0800148 uint64_t* rootfs_size,
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800149 chromeos::Blob* rootfs_hash);
Darin Petkov2dd01092010-10-08 15:43:05 -0700150
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700151 // Converts an ordered collection of Extent objects which contain data of
152 // length full_length to a comma-separated string. For each Extent, the
153 // string will have the start offset and then the length in bytes.
154 // The length value of the last extent in the string may be short, since
155 // the full length of all extents in the string is capped to full_length.
156 // Also, an extent starting at kSparseHole, appears as -1 in the string.
157 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1},
158 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13,
159 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
160 static bool ExtentsToBsdiffPositionsString(
161 const google::protobuf::RepeatedPtrField<Extent>& extents,
162 uint64_t block_size,
163 uint64_t full_length,
164 std::string* positions_string);
165
Darin Petkov0406e402010-10-06 21:33:11 -0700166 // Returns true if a previous update attempt can be continued based on the
167 // persistent preferences and the new update check response hash.
168 static bool CanResumeUpdate(PrefsInterface* prefs,
169 std::string update_check_response_hash);
170
171 // Resets the persistent update progress state to indicate that an update
Darin Petkov9b230572010-10-08 10:20:09 -0700172 // can't be resumed. Performs a quick update-in-progress reset if |quick| is
173 // true, otherwise resets all progress-related update state. Returns true on
174 // success, false otherwise.
175 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick);
Darin Petkov0406e402010-10-06 21:33:11 -0700176
Darin Petkov9574f7e2011-01-13 10:48:12 -0800177 // Attempts to parse the update metadata starting from the beginning of
Gilad Arnolddaa27402014-01-23 11:56:17 -0800178 // |payload|. On success, returns kMetadataParseSuccess. Returns
Gilad Arnoldfe133932014-01-14 12:25:50 -0800179 // kMetadataParseInsufficientData if more data is needed to parse the complete
180 // metadata. Returns kMetadataParseError if the metadata can't be parsed given
181 // the payload.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800182 MetadataParseResult ParsePayloadMetadata(const chromeos::Blob& payload,
Gilad Arnolddaa27402014-01-23 11:56:17 -0800183 ErrorCode* error);
Darin Petkov9574f7e2011-01-13 10:48:12 -0800184
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700185 void set_public_key_path(const std::string& public_key_path) {
186 public_key_path_ = public_key_path;
Darin Petkov698d0412010-10-13 10:59:44 -0700187 }
188
Don Garrett4d039442013-10-28 18:40:06 -0700189 // Returns the byte offset at which the payload version can be found.
190 static uint64_t GetVersionOffset();
Jay Srinivasanf4318702012-09-24 11:56:24 -0700191
192 // Returns the byte offset where the size of the manifest is stored in
193 // a payload. This offset precedes the actual start of the manifest
194 // that's returned by the GetManifestOffset method.
195 static uint64_t GetManifestSizeOffset();
196
Don Garrett4d039442013-10-28 18:40:06 -0700197 // Returns the byte offset at which the manifest protobuf begins in a
198 // payload.
199 static uint64_t GetManifestOffset();
200
Gilad Arnoldfe133932014-01-14 12:25:50 -0800201 // Returns the size of the payload metadata, which includes the payload header
202 // and the manifest. Is the header was not yet parsed, returns zero.
203 uint64_t GetMetadataSize() const;
204
Gilad Arnolddaa27402014-01-23 11:56:17 -0800205 // If the manifest was successfully parsed, copies it to |*out_manifest_p|.
206 // Returns true on success.
207 bool GetManifest(DeltaArchiveManifest* out_manifest_p) const;
208
Allie Woodfdf00512015-03-02 13:34:55 -0800209 // Returns the delta minor version. If this value is defined in the manifest,
210 // it returns that value, otherwise it returns the default value.
211 uint32_t GetMinorVersion() const;
212
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700213 private:
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700214 friend class DeltaPerformerTest;
Sen Jianga4365d62015-09-25 10:52:25 -0700215 friend class DeltaPerformerIntegrationTest;
David Zeuthene7f89172013-10-31 10:21:04 -0700216 FRIEND_TEST(DeltaPerformerTest, UsePublicKeyFromResponse);
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700217
Gilad Arnoldfe133932014-01-14 12:25:50 -0800218 // Appends up to |*count_p| bytes from |*bytes_p| to |buffer_|, but only to
219 // the extent that the size of |buffer_| does not exceed |max|. Advances
220 // |*cbytes_p| and decreases |*count_p| by the actual number of bytes copied,
221 // and returns this number.
222 size_t CopyDataToBuffer(const char** bytes_p, size_t* count_p, size_t max);
223
224 // If |op_result| is false, emits an error message using |op_type_name| and
225 // sets |*error| accordingly. Otherwise does nothing. Returns |op_result|.
226 bool HandleOpResult(bool op_result, const char* op_type_name,
227 ErrorCode* error);
228
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800229 // Logs the progress of downloading/applying an update.
230 void LogProgress(const char* message_prefix);
231
232 // Update overall progress metrics, log as necessary.
233 void UpdateOverallProgress(bool force_log, const char* message_prefix);
234
Darin Petkov698d0412010-10-13 10:59:44 -0700235 // Verifies that the expected source partition hashes (if present) match the
Alex Vakulenko072359c2014-07-18 11:41:07 -0700236 // hashes for the current partitions. Returns true if there are no expected
Darin Petkov698d0412010-10-13 10:59:44 -0700237 // hashes in the payload (e.g., if it's a new-style full update) or if the
238 // hashes match; returns false otherwise.
239 bool VerifySourcePartitions();
240
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700241 // Returns true if enough of the delta file has been passed via Write()
242 // to be able to perform a given install operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700243 bool CanPerformInstallOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700244
Gilad Arnold21504f02013-05-24 08:51:22 -0700245 // Checks the integrity of the payload manifest. Returns true upon success,
246 // false otherwise.
247 ErrorCode ValidateManifest();
248
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700249 // Validates that the hash of the blobs corresponding to the given |operation|
250 // matches what's specified in the manifest in the payload.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700251 // Returns ErrorCode::kSuccess on match or a suitable error code otherwise.
Alex Deymoa12ee112015-08-12 22:19:32 -0700252 ErrorCode ValidateOperationHash(const InstallOperation& operation);
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700253
254 // Interprets the given |protobuf| as a DeltaArchiveManifest protocol buffer
255 // of the given protobuf_length and verifies that the signed hash of the
Jay Srinivasanf4318702012-09-24 11:56:24 -0700256 // metadata matches what's specified in the install plan from Omaha.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700257 // Returns ErrorCode::kSuccess on match or a suitable error code otherwise.
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700258 // This method must be called before any part of the |protobuf| is parsed
259 // so that a man-in-the-middle attack on the SSL connection to the payload
260 // server doesn't exploit any vulnerability in the code that parses the
261 // protocol buffer.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800262 ErrorCode ValidateMetadataSignature(const void* protobuf,
263 uint64_t protobuf_length);
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700264
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700265 // Returns true on success.
Alex Deymoa12ee112015-08-12 22:19:32 -0700266 bool PerformInstallOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700267
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700268 // These perform a specific type of operation and return true on success.
Alex Deymoa12ee112015-08-12 22:19:32 -0700269 bool PerformReplaceOperation(const InstallOperation& operation,
270 bool is_kernel_partition);
271 bool PerformMoveOperation(const InstallOperation& operation,
272 bool is_kernel_partition);
273 bool PerformBsdiffOperation(const InstallOperation& operation,
274 bool is_kernel_partition);
275 bool PerformSourceCopyOperation(const InstallOperation& operation,
276 bool is_kernel_partition);
277 bool PerformSourceBsdiffOperation(const InstallOperation& operation,
278 bool is_kernel_partition);
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700279
Darin Petkovd7061ab2010-10-06 14:37:09 -0700280 // Returns true if the payload signature message has been extracted from
281 // |operation|, false otherwise.
Alex Deymoa12ee112015-08-12 22:19:32 -0700282 bool ExtractSignatureMessage(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700283
Gilad Arnoldfe133932014-01-14 12:25:50 -0800284 // Updates the hash calculator with the bytes in |buffer_|. Then discard the
Gilad Arnolddaa27402014-01-23 11:56:17 -0800285 // content, ensuring that memory is being deallocated. If |do_advance_offset|,
286 // advances the internal offset counter accordingly.
287 void DiscardBuffer(bool do_advance_offset);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700288
Darin Petkov0406e402010-10-06 21:33:11 -0700289 // Checkpoints the update progress into persistent storage to allow this
290 // update attempt to be resumed after reboot.
Darin Petkov73058b42010-10-06 16:32:19 -0700291 bool CheckpointUpdateProgress();
292
Darin Petkov9b230572010-10-08 10:20:09 -0700293 // Primes the required update state. Returns true if the update state was
294 // successfully initialized to a saved resume state or if the update is a new
295 // update. Returns false otherwise.
296 bool PrimeUpdateState();
297
David Zeuthene7f89172013-10-31 10:21:04 -0700298 // If the Omaha response contains a public RSA key and we're allowed
299 // to use it (e.g. if we're in developer mode), extract the key from
300 // the response and store it in a temporary file and return true. In
301 // the affirmative the path to the temporary file is stored in
302 // |out_tmp_key| and it is the responsibility of the caller to clean
303 // it up.
304 bool GetPublicKeyFromResponse(base::FilePath *out_tmp_key);
305
Darin Petkov73058b42010-10-06 16:32:19 -0700306 // Update Engine preference store.
307 PrefsInterface* prefs_;
308
Jay Srinivasanf0572052012-10-23 18:12:56 -0700309 // Global context of the system.
310 SystemState* system_state_;
311
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700312 // Install Plan based on Omaha Response.
313 InstallPlan* install_plan_;
314
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700315 // File descriptor of open device.
Nam T. Nguyenf1d582e2014-12-08 15:07:17 -0800316 FileDescriptorPtr fd_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700317
Allie Woodfdf00512015-03-02 13:34:55 -0800318 // File descriptor of the kernel device.
Nam T. Nguyenf1d582e2014-12-08 15:07:17 -0800319 FileDescriptorPtr kernel_fd_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700320
Allie Woodfdf00512015-03-02 13:34:55 -0800321 // File descriptor of the source device.
322 FileDescriptorPtr source_fd_;
323
324 // File descriptor of the source kernel device.
325 FileDescriptorPtr source_kernel_fd_;
326
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700327 std::string path_; // Path that fd_ refers to.
328 std::string kernel_path_; // Path that kernel_fd_ refers to.
Darin Petkovd7061ab2010-10-06 14:37:09 -0700329
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700330 DeltaArchiveManifest manifest_;
Gilad Arnolddaa27402014-01-23 11:56:17 -0800331 bool manifest_parsed_;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700332 bool manifest_valid_;
Gilad Arnoldfe133932014-01-14 12:25:50 -0800333 uint64_t metadata_size_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700334
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700335 // Index of the next operation to perform in the manifest.
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800336 size_t next_operation_num_;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700337
Gilad Arnoldfe133932014-01-14 12:25:50 -0800338 // A buffer used for accumulating downloaded data. Initially, it stores the
339 // payload metadata; once that's downloaded and parsed, it stores data for the
340 // next update operation.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800341 chromeos::Blob buffer_;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700342 // Offset of buffer_ in the binary blobs section of the update.
343 uint64_t buffer_offset_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700344
Darin Petkov0406e402010-10-06 21:33:11 -0700345 // Last |buffer_offset_| value updated as part of the progress update.
346 uint64_t last_updated_buffer_offset_;
347
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700348 // The block size (parsed from the manifest).
349 uint32_t block_size_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700350
Darin Petkov437adc42010-10-07 13:12:24 -0700351 // Calculates the payload hash.
Darin Petkovd7061ab2010-10-06 14:37:09 -0700352 OmahaHashCalculator hash_calculator_;
353
Darin Petkov437adc42010-10-07 13:12:24 -0700354 // Saves the signed hash context.
355 std::string signed_hash_context_;
356
Darin Petkovd7061ab2010-10-06 14:37:09 -0700357 // Signatures message blob extracted directly from the payload.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800358 chromeos::Blob signatures_message_data_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700359
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700360 // The public key to be used. Provided as a member so that tests can
361 // override with test keys.
362 std::string public_key_path_;
Darin Petkov698d0412010-10-13 10:59:44 -0700363
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800364 // The number of bytes received so far, used for progress tracking.
365 size_t total_bytes_received_;
366
367 // The number rootfs and total operations in a payload, once we know them.
368 size_t num_rootfs_operations_;
369 size_t num_total_operations_;
370
371 // An overall progress counter, which should reflect both download progress
372 // and the ratio of applied operations. Range is 0-100.
373 unsigned overall_progress_;
374
375 // The last progress chunk recorded.
376 unsigned last_progress_chunk_;
377
378 // The timeout after which we should force emitting a progress log (constant),
379 // and the actual point in time for the next forced log to be emitted.
380 const base::TimeDelta forced_progress_log_wait_;
381 base::Time forced_progress_log_time_;
382
Allie Woodfdf00512015-03-02 13:34:55 -0800383 // The delta minor payload version supported by DeltaPerformer.
384 uint32_t supported_minor_version_;
385
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700386 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
387};
388
389} // namespace chromeos_update_engine
390
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700391#endif // UPDATE_ENGINE_DELTA_PERFORMER_H_