Alex Deymo | 477aec2 | 2015-03-24 23:40:48 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_ANNOTATED_OPERATION_H_ |
| 6 | #define UPDATE_ENGINE_PAYLOAD_GENERATOR_ANNOTATED_OPERATION_H_ |
| 7 | |
| 8 | #include <ostream> // NOLINT(readability/streams) |
| 9 | #include <string> |
| 10 | |
Gilad Arnold | 41e3474 | 2015-05-11 11:31:50 -0700 | [diff] [blame^] | 11 | #include <chromeos/secure_blob.h> |
Alex Deymo | 477aec2 | 2015-03-24 23:40:48 -0700 | [diff] [blame] | 12 | #include "update_engine/update_metadata.pb.h" |
| 13 | |
| 14 | namespace chromeos_update_engine { |
| 15 | |
| 16 | struct AnnotatedOperation { |
| 17 | // The name given to the operation, for logging and debugging purposes only. |
| 18 | // This normally includes the path to the file and the chunk used, if any. |
| 19 | std::string name; |
| 20 | |
| 21 | // The InstallOperation, as defined by the protobuf. |
| 22 | DeltaArchiveManifest_InstallOperation op; |
| 23 | |
| 24 | // Sets |name| to a human readable representation of a chunk in a file. |
| 25 | void SetNameFromFileAndChunk(const std::string& filename, |
| 26 | off_t chunk_offset, off_t chunk_size); |
Gilad Arnold | 41e3474 | 2015-05-11 11:31:50 -0700 | [diff] [blame^] | 27 | |
| 28 | // Writes |blob| to the end of |data_fd|, and updates |data_file_size| to |
| 29 | // match the new size of |data_fd|. It sets the data_offset and data_length |
| 30 | // in AnnotatedOperation to match the offset and size of |blob| in |data_fd|. |
| 31 | bool SetOperationBlob(chromeos::Blob* blob, int data_fd, |
| 32 | off_t* data_file_size); |
Alex Deymo | 477aec2 | 2015-03-24 23:40:48 -0700 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | // For logging purposes. |
| 36 | std::ostream& operator<<(std::ostream& os, const AnnotatedOperation& aop); |
| 37 | |
| 38 | std::string InstallOperationTypeName( |
| 39 | DeltaArchiveManifest_InstallOperation_Type op_type); |
| 40 | |
| 41 | } // namespace chromeos_update_engine |
| 42 | |
| 43 | #endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_ANNOTATED_OPERATION_H_ |