blob: 64ad4afa9d79a3cd6b025b68b9e2c3b75f398be4 [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
Sen Jiangb8060e42015-09-24 17:30:50 -070053 static const uint64_t kDeltaVersionOffset;
Jay Srinivasanf4318702012-09-24 11:56:24 -070054 static const uint64_t kDeltaVersionSize;
Sen Jiangb8060e42015-09-24 17:30:50 -070055 static const uint64_t kDeltaManifestSizeOffset;
Jay Srinivasanf4318702012-09-24 11:56:24 -070056 static const uint64_t kDeltaManifestSizeSize;
Sen Jiangb8060e42015-09-24 17:30:50 -070057 static const uint64_t kDeltaMetadataSignatureSizeSize;
58 static const uint64_t kMaxPayloadHeaderSize;
Don Garrett4d039442013-10-28 18:40:06 -070059 static const uint64_t kSupportedMajorPayloadVersion;
Alex Deymoe5e5fe92015-10-05 09:28:19 -070060 static const uint32_t kSupportedMinorPayloadVersion;
Darin Petkovabc7bc02011-02-23 14:39:43 -080061
Gilad Arnold8a86fa52013-01-15 12:35:05 -080062 // Defines the granularity of progress logging in terms of how many "completed
63 // chunks" we want to report at the most.
64 static const unsigned kProgressLogMaxChunks;
65 // Defines a timeout since the last progress was logged after which we want to
66 // force another log message (even if the current chunk was not completed).
67 static const unsigned kProgressLogTimeoutSeconds;
68 // These define the relative weights (0-100) we give to the different work
69 // components associated with an update when computing an overall progress.
70 // Currently they include the download progress and the number of completed
71 // operations. They must add up to one hundred (100).
72 static const unsigned kProgressDownloadWeight;
73 static const unsigned kProgressOperationsWeight;
74
Jay Srinivasanf0572052012-10-23 18:12:56 -070075 DeltaPerformer(PrefsInterface* prefs,
76 SystemState* system_state,
77 InstallPlan* install_plan)
Darin Petkov73058b42010-10-06 16:32:19 -070078 : prefs_(prefs),
Jay Srinivasanf0572052012-10-23 18:12:56 -070079 system_state_(system_state),
Alex Deymoe5e5fe92015-10-05 09:28:19 -070080 install_plan_(install_plan) {}
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070081
Jay Srinivasan51dcf262012-09-13 17:24:32 -070082 // FileWriter's Write implementation where caller doesn't care about
83 // error codes.
Alex Deymo610277e2014-11-11 21:18:11 -080084 bool Write(const void* bytes, size_t count) override {
David Zeuthena99981f2013-04-29 13:42:47 -070085 ErrorCode error;
Jay Srinivasan51dcf262012-09-13 17:24:32 -070086 return Write(bytes, count, &error);
87 }
88
89 // FileWriter's Write implementation that returns a more specific |error| code
90 // in case of failures in Write operation.
Alex Deymo610277e2014-11-11 21:18:11 -080091 bool Write(const void* bytes, size_t count, ErrorCode *error) override;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070092
93 // Wrapper around close. Returns 0 on success or -errno on error.
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -070094 // Closes both 'path' given to Open() and the kernel path.
Alex Deymo610277e2014-11-11 21:18:11 -080095 int Close() override;
Darin Petkovd7061ab2010-10-06 14:37:09 -070096
Alex Deymoe5e5fe92015-10-05 09:28:19 -070097 // Open the target and source (if delta payload) file descriptors for the
98 // |current_partition_|. The manifest needs to be already parsed for this to
99 // work. Returns whether the required file descriptors were successfully open.
100 bool OpenCurrentPartition();
101
102 // Closes the current partition file descriptors if open. Returns 0 on success
103 // or -errno on error.
104 int CloseCurrentPartition();
105
David Zeuthen8f191b22013-08-06 12:27:50 -0700106 // Returns |true| only if the manifest has been processed and it's valid.
107 bool IsManifestValid();
108
Darin Petkovd7061ab2010-10-06 14:37:09 -0700109 // Verifies the downloaded payload against the signed hash included in the
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700110 // payload, against the update check hash (which is in base64 format) and
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700111 // size using the public key and returns ErrorCode::kSuccess on success, an
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700112 // error code on failure. This method should be called after closing the
113 // stream. Note this method skips the signed hash check if the public key is
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700114 // unavailable; it returns ErrorCode::kSignedDeltaPayloadExpectedError if the
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700115 // public key is available but the delta payload doesn't include a signature.
David Zeuthena99981f2013-04-29 13:42:47 -0700116 ErrorCode VerifyPayload(const std::string& update_check_response_hash,
Allie Wood9f6f0a52015-03-30 11:25:47 -0700117 const uint64_t update_check_response_size);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700118
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700119 // Converts an ordered collection of Extent objects which contain data of
120 // length full_length to a comma-separated string. For each Extent, the
121 // string will have the start offset and then the length in bytes.
122 // The length value of the last extent in the string may be short, since
123 // the full length of all extents in the string is capped to full_length.
124 // Also, an extent starting at kSparseHole, appears as -1 in the string.
125 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1},
126 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13,
127 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
128 static bool ExtentsToBsdiffPositionsString(
129 const google::protobuf::RepeatedPtrField<Extent>& extents,
130 uint64_t block_size,
131 uint64_t full_length,
132 std::string* positions_string);
133
Darin Petkov0406e402010-10-06 21:33:11 -0700134 // Returns true if a previous update attempt can be continued based on the
135 // persistent preferences and the new update check response hash.
136 static bool CanResumeUpdate(PrefsInterface* prefs,
137 std::string update_check_response_hash);
138
139 // Resets the persistent update progress state to indicate that an update
Darin Petkov9b230572010-10-08 10:20:09 -0700140 // can't be resumed. Performs a quick update-in-progress reset if |quick| is
141 // true, otherwise resets all progress-related update state. Returns true on
142 // success, false otherwise.
143 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick);
Darin Petkov0406e402010-10-06 21:33:11 -0700144
Darin Petkov9574f7e2011-01-13 10:48:12 -0800145 // Attempts to parse the update metadata starting from the beginning of
Gilad Arnolddaa27402014-01-23 11:56:17 -0800146 // |payload|. On success, returns kMetadataParseSuccess. Returns
Gilad Arnoldfe133932014-01-14 12:25:50 -0800147 // kMetadataParseInsufficientData if more data is needed to parse the complete
148 // metadata. Returns kMetadataParseError if the metadata can't be parsed given
149 // the payload.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800150 MetadataParseResult ParsePayloadMetadata(const chromeos::Blob& payload,
Gilad Arnolddaa27402014-01-23 11:56:17 -0800151 ErrorCode* error);
Darin Petkov9574f7e2011-01-13 10:48:12 -0800152
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700153 void set_public_key_path(const std::string& public_key_path) {
154 public_key_path_ = public_key_path;
Darin Petkov698d0412010-10-13 10:59:44 -0700155 }
156
Sen Jiangb8060e42015-09-24 17:30:50 -0700157 // Set |*out_offset| to the byte offset where the size of the metadata signature
158 // is stored in a payload. Return true on success, if this field is not
159 // present in the payload, return false.
160 bool GetMetadataSignatureSizeOffset(uint64_t* out_offset) const;
Jay Srinivasanf4318702012-09-24 11:56:24 -0700161
Sen Jiangb8060e42015-09-24 17:30:50 -0700162 // Set |*out_offset| to the byte offset at which the manifest protobuf begins
163 // in a payload. Return true on success, false if the offset is unknown.
164 bool GetManifestOffset(uint64_t* out_offset) const;
Don Garrett4d039442013-10-28 18:40:06 -0700165
Gilad Arnoldfe133932014-01-14 12:25:50 -0800166 // Returns the size of the payload metadata, which includes the payload header
Sen Jiangb8060e42015-09-24 17:30:50 -0700167 // and the manifest. If the header was not yet parsed, returns zero.
Gilad Arnoldfe133932014-01-14 12:25:50 -0800168 uint64_t GetMetadataSize() const;
169
Gilad Arnolddaa27402014-01-23 11:56:17 -0800170 // If the manifest was successfully parsed, copies it to |*out_manifest_p|.
171 // Returns true on success.
172 bool GetManifest(DeltaArchiveManifest* out_manifest_p) const;
173
Sen Jiangb8060e42015-09-24 17:30:50 -0700174 // Return true if header parsing is finished and no errors occurred.
175 bool IsHeaderParsed() const;
176
177 // Returns the major payload version. If the version was not yet parsed,
178 // returns zero.
179 uint64_t GetMajorVersion() const;
180
Allie Woodfdf00512015-03-02 13:34:55 -0800181 // Returns the delta minor version. If this value is defined in the manifest,
182 // it returns that value, otherwise it returns the default value.
183 uint32_t GetMinorVersion() const;
184
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700185 private:
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700186 friend class DeltaPerformerTest;
Sen Jianga4365d62015-09-25 10:52:25 -0700187 friend class DeltaPerformerIntegrationTest;
David Zeuthene7f89172013-10-31 10:21:04 -0700188 FRIEND_TEST(DeltaPerformerTest, UsePublicKeyFromResponse);
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700189
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700190 // Parse and move the update instructions of all partitions into our local
191 // |partitions_| variable based on the version of the payload. Requires the
192 // manifest to be parsed and valid.
193 bool ParseManifestPartitions(ErrorCode* error);
194
Gilad Arnoldfe133932014-01-14 12:25:50 -0800195 // Appends up to |*count_p| bytes from |*bytes_p| to |buffer_|, but only to
196 // the extent that the size of |buffer_| does not exceed |max|. Advances
197 // |*cbytes_p| and decreases |*count_p| by the actual number of bytes copied,
198 // and returns this number.
199 size_t CopyDataToBuffer(const char** bytes_p, size_t* count_p, size_t max);
200
201 // If |op_result| is false, emits an error message using |op_type_name| and
202 // sets |*error| accordingly. Otherwise does nothing. Returns |op_result|.
203 bool HandleOpResult(bool op_result, const char* op_type_name,
204 ErrorCode* error);
205
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800206 // Logs the progress of downloading/applying an update.
207 void LogProgress(const char* message_prefix);
208
209 // Update overall progress metrics, log as necessary.
210 void UpdateOverallProgress(bool force_log, const char* message_prefix);
211
Darin Petkov698d0412010-10-13 10:59:44 -0700212 // Verifies that the expected source partition hashes (if present) match the
Alex Vakulenko072359c2014-07-18 11:41:07 -0700213 // hashes for the current partitions. Returns true if there are no expected
Darin Petkov698d0412010-10-13 10:59:44 -0700214 // hashes in the payload (e.g., if it's a new-style full update) or if the
215 // hashes match; returns false otherwise.
216 bool VerifySourcePartitions();
217
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700218 // Returns true if enough of the delta file has been passed via Write()
219 // to be able to perform a given install operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700220 bool CanPerformInstallOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700221
Gilad Arnold21504f02013-05-24 08:51:22 -0700222 // Checks the integrity of the payload manifest. Returns true upon success,
223 // false otherwise.
224 ErrorCode ValidateManifest();
225
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700226 // Validates that the hash of the blobs corresponding to the given |operation|
227 // matches what's specified in the manifest in the payload.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700228 // Returns ErrorCode::kSuccess on match or a suitable error code otherwise.
Alex Deymoa12ee112015-08-12 22:19:32 -0700229 ErrorCode ValidateOperationHash(const InstallOperation& operation);
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700230
231 // Interprets the given |protobuf| as a DeltaArchiveManifest protocol buffer
232 // of the given protobuf_length and verifies that the signed hash of the
Jay Srinivasanf4318702012-09-24 11:56:24 -0700233 // metadata matches what's specified in the install plan from Omaha.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700234 // Returns ErrorCode::kSuccess on match or a suitable error code otherwise.
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700235 // This method must be called before any part of the |protobuf| is parsed
236 // so that a man-in-the-middle attack on the SSL connection to the payload
237 // server doesn't exploit any vulnerability in the code that parses the
238 // protocol buffer.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800239 ErrorCode ValidateMetadataSignature(const void* protobuf,
240 uint64_t protobuf_length);
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700241
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700242 // Returns true on success.
Alex Deymoa12ee112015-08-12 22:19:32 -0700243 bool PerformInstallOperation(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700244
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700245 // These perform a specific type of operation and return true on success.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700246 bool PerformReplaceOperation(const InstallOperation& operation);
247 bool PerformZeroOrDiscardOperation(const InstallOperation& operation);
248 bool PerformMoveOperation(const InstallOperation& operation);
249 bool PerformBsdiffOperation(const InstallOperation& operation);
250 bool PerformSourceCopyOperation(const InstallOperation& operation);
251 bool PerformSourceBsdiffOperation(const InstallOperation& operation);
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700252
Darin Petkovd7061ab2010-10-06 14:37:09 -0700253 // Returns true if the payload signature message has been extracted from
254 // |operation|, false otherwise.
Alex Deymoa12ee112015-08-12 22:19:32 -0700255 bool ExtractSignatureMessage(const InstallOperation& operation);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700256
Gilad Arnoldfe133932014-01-14 12:25:50 -0800257 // Updates the hash calculator with the bytes in |buffer_|. Then discard the
Gilad Arnolddaa27402014-01-23 11:56:17 -0800258 // content, ensuring that memory is being deallocated. If |do_advance_offset|,
259 // advances the internal offset counter accordingly.
260 void DiscardBuffer(bool do_advance_offset);
Darin Petkovd7061ab2010-10-06 14:37:09 -0700261
Darin Petkov0406e402010-10-06 21:33:11 -0700262 // Checkpoints the update progress into persistent storage to allow this
263 // update attempt to be resumed after reboot.
Darin Petkov73058b42010-10-06 16:32:19 -0700264 bool CheckpointUpdateProgress();
265
Darin Petkov9b230572010-10-08 10:20:09 -0700266 // Primes the required update state. Returns true if the update state was
267 // successfully initialized to a saved resume state or if the update is a new
268 // update. Returns false otherwise.
269 bool PrimeUpdateState();
270
David Zeuthene7f89172013-10-31 10:21:04 -0700271 // If the Omaha response contains a public RSA key and we're allowed
272 // to use it (e.g. if we're in developer mode), extract the key from
273 // the response and store it in a temporary file and return true. In
274 // the affirmative the path to the temporary file is stored in
275 // |out_tmp_key| and it is the responsibility of the caller to clean
276 // it up.
277 bool GetPublicKeyFromResponse(base::FilePath *out_tmp_key);
278
Darin Petkov73058b42010-10-06 16:32:19 -0700279 // Update Engine preference store.
280 PrefsInterface* prefs_;
281
Jay Srinivasanf0572052012-10-23 18:12:56 -0700282 // Global context of the system.
283 SystemState* system_state_;
284
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700285 // Install Plan based on Omaha Response.
286 InstallPlan* install_plan_;
287
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700288 // File descriptor of the source partition. Only set while updating a
289 // partition when using a delta payload.
290 FileDescriptorPtr source_fd_{nullptr};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700291
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700292 // File descriptor of the target partition. Only set while performing the
293 // operations of a given partition.
294 FileDescriptorPtr target_fd_{nullptr};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700295
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700296 // Paths the |source_fd_| and |target_fd_| refer to.
297 std::string source_path_;
298 std::string target_path_;
Allie Woodfdf00512015-03-02 13:34:55 -0800299
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700300 // Parsed manifest. Set after enough bytes to parse the manifest were
301 // downloaded.
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700302 DeltaArchiveManifest manifest_;
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700303 bool manifest_parsed_{false};
304 bool manifest_valid_{false};
305 uint64_t metadata_size_{0};
306 uint64_t manifest_size_{0};
307 uint64_t major_payload_version_{0};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700308
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700309 // Accumulated number of operations per partition. The i-th element is the
310 // sum of the number of operations for all the partitions from 0 to i
311 // inclusive. Valid when |manifest_valid_| is true.
312 std::vector<size_t> acc_num_operations_;
313
314 // The total operations in a payload. Valid when |manifest_valid_| is true,
315 // otherwise 0.
316 size_t num_total_operations_{0};
317
318 // The list of partitions to update as found in the manifest major version 2.
319 // When parsing an older manifest format, the information is converted over to
320 // this format instead.
321 std::vector<PartitionUpdate> partitions_;
322
323 // Index in the list of partitions (|partitions_| member) of the current
324 // partition being processed.
325 size_t current_partition_{0};
326
327 // Index of the next operation to perform in the manifest. The index is linear
328 // on the total number of operation on the manifest.
329 size_t next_operation_num_{0};
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700330
Gilad Arnoldfe133932014-01-14 12:25:50 -0800331 // A buffer used for accumulating downloaded data. Initially, it stores the
332 // payload metadata; once that's downloaded and parsed, it stores data for the
333 // next update operation.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800334 chromeos::Blob buffer_;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700335 // Offset of buffer_ in the binary blobs section of the update.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700336 uint64_t buffer_offset_{0};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700337
Darin Petkov0406e402010-10-06 21:33:11 -0700338 // Last |buffer_offset_| value updated as part of the progress update.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700339 uint64_t last_updated_buffer_offset_{kuint64max};
Darin Petkov0406e402010-10-06 21:33:11 -0700340
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700341 // The block size (parsed from the manifest).
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700342 uint32_t block_size_{0};
Darin Petkovd7061ab2010-10-06 14:37:09 -0700343
Darin Petkov437adc42010-10-07 13:12:24 -0700344 // Calculates the payload hash.
Darin Petkovd7061ab2010-10-06 14:37:09 -0700345 OmahaHashCalculator hash_calculator_;
346
Darin Petkov437adc42010-10-07 13:12:24 -0700347 // Saves the signed hash context.
348 std::string signed_hash_context_;
349
Darin Petkovd7061ab2010-10-06 14:37:09 -0700350 // Signatures message blob extracted directly from the payload.
Alex Vakulenkof68bbbc2015-02-09 12:53:18 -0800351 chromeos::Blob signatures_message_data_;
Darin Petkovd7061ab2010-10-06 14:37:09 -0700352
Jay Srinivasan51dcf262012-09-13 17:24:32 -0700353 // The public key to be used. Provided as a member so that tests can
354 // override with test keys.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700355 std::string public_key_path_{constants::kUpdatePayloadPublicKeyPath};
Darin Petkov698d0412010-10-13 10:59:44 -0700356
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800357 // The number of bytes received so far, used for progress tracking.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700358 size_t total_bytes_received_{0};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800359
360 // An overall progress counter, which should reflect both download progress
361 // and the ratio of applied operations. Range is 0-100.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700362 unsigned overall_progress_{0};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800363
364 // The last progress chunk recorded.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700365 unsigned last_progress_chunk_{0};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800366
367 // The timeout after which we should force emitting a progress log (constant),
368 // and the actual point in time for the next forced log to be emitted.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700369 const base::TimeDelta forced_progress_log_wait_{
370 base::TimeDelta::FromSeconds(kProgressLogTimeoutSeconds)};
Gilad Arnold8a86fa52013-01-15 12:35:05 -0800371 base::Time forced_progress_log_time_;
372
Sen Jiangb8060e42015-09-24 17:30:50 -0700373 // The payload major payload version supported by DeltaPerformer.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700374 uint64_t supported_major_version_{kSupportedMajorPayloadVersion};
Sen Jiangb8060e42015-09-24 17:30:50 -0700375
Allie Woodfdf00512015-03-02 13:34:55 -0800376 // The delta minor payload version supported by DeltaPerformer.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700377 uint32_t supported_minor_version_{kSupportedMinorPayloadVersion};
Allie Woodfdf00512015-03-02 13:34:55 -0800378
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700379 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
380};
381
382} // namespace chromeos_update_engine
383
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700384#endif // UPDATE_ENGINE_DELTA_PERFORMER_H_