10792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang//
20792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// Copyright (C) 2015 The Android Open Source Project
30792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang//
40792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// Licensed under the Apache License, Version 2.0 (the "License");
50792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// you may not use this file except in compliance with the License.
60792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// You may obtain a copy of the License at
70792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang//
80792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang//      http://www.apache.org/licenses/LICENSE-2.0
90792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang//
100792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// Unless required by applicable law or agreed to in writing, software
110792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// distributed under the License is distributed on an "AS IS" BASIS,
120792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// See the License for the specific language governing permissions and
140792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang// limitations under the License.
150792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang//
160792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
170792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang#ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_ANNOTATED_OPERATION_H_
180792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang#define UPDATE_ENGINE_PAYLOAD_GENERATOR_ANNOTATED_OPERATION_H_
19ed0864557b3340ab7db00e2dc95b29c4b8bb485dJinsuk Kim
20ed0864557b3340ab7db00e2dc95b29c4b8bb485dJinsuk Kim#include <ostream>  // NOLINT(readability/streams)
215008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim#include <string>
225008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim
235008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim#include <brillo/secure_blob.h>
245008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim
255008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim#include "update_engine/payload_generator/blob_file_writer.h"
265b8cb00b8a302329b98a5528eaa7934d0f5c3e65Jinsuk Kim#include "update_engine/update_metadata.pb.h"
275008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim
285008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimnamespace chromeos_update_engine {
295008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim
305b8cb00b8a302329b98a5528eaa7934d0f5c3e65Jinsuk Kimstruct AnnotatedOperation {
315008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim  // The name given to the operation, for logging and debugging purposes only.
320792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang  // This normally includes the path to the file and the chunk used, if any.
3338db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo  std::string name;
347ecfbaed6e902aea151bc1919cf7771bbd868fc4Jinsuk Kim
350792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang  // The InstallOperation, as defined by the protobuf.
3638db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo  InstallOperation op;
3738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo
385008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim  // Writes |blob| to the end of |blob_file|. It sets the data_offset and
39c0c20d0522d7756d80f011e7a54bf3b51c78df41Jinsuk Kim  // data_length in AnnotatedOperation to match the offset and size of |blob|
407d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo  // in |blob_file|.
4160cffce420db4c3395f86d3b9bb36003adf26f5dJungshik Jang  bool SetOperationBlob(const brillo::Blob& blob, BlobFileWriter* blob_file);
420340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim};
43d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang
44d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang// For logging purposes.
456d97f5b91c6c82f28a2a3a5d3b922f0e5844e733Jinsuk Kimstd::ostream& operator<<(std::ostream& os, const AnnotatedOperation& aop);
46d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang
479c37e1f53ea4734bfe5ae156dc5399ce5f2c7cccJinsuk Kim}  // namespace chromeos_update_engine
48b3fbf9dbe8d41d91efbac2118b676af74592257bJinsuk Kim
4912e5dcefe136b58562f39604e6a8460ac92cb895Jungshik Jang#endif  // UPDATE_ENGINE_PAYLOAD_GENERATOR_ANNOTATED_OPERATION_H_
50ea67c183fe5511ad99aeaae1a32b5245bd020e36Jungshik Jang