1 // 2 // Copyright (C) 2021 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 // 16 17 #ifndef UPDATE_ENGINE_INSTALL_OPERATION_EXECUTOR_H 18 #define UPDATE_ENGINE_INSTALL_OPERATION_EXECUTOR_H 19 20 #include <memory> 21 22 #include "update_engine/payload_consumer/extent_writer.h" 23 #include "update_engine/payload_consumer/file_descriptor.h" 24 #include "update_engine/update_metadata.pb.h" 25 26 namespace chromeos_update_engine { 27 28 class InstallOperationExecutor { 29 public: InstallOperationExecutor(size_t block_size)30 explicit InstallOperationExecutor(size_t block_size) 31 : block_size_(block_size) {} 32 33 bool ExecuteReplaceOperation(const InstallOperation& operation, 34 std::unique_ptr<ExtentWriter> writer, 35 const void* data, 36 size_t count); 37 bool ExecuteZeroOrDiscardOperation(const InstallOperation& operation, 38 std::unique_ptr<ExtentWriter> writer); 39 bool ExecuteSourceCopyOperation(const InstallOperation& operation, 40 std::unique_ptr<ExtentWriter> writer, 41 FileDescriptorPtr source_fd); 42 43 bool ExecuteDiffOperation(const InstallOperation& operation, 44 std::unique_ptr<ExtentWriter> writer, 45 FileDescriptorPtr source_fd, 46 const void* data, 47 size_t count); 48 49 private: 50 bool ExecuteSourceBsdiffOperation(const InstallOperation& operation, 51 std::unique_ptr<ExtentWriter> writer, 52 FileDescriptorPtr source_fd, 53 const void* data, 54 size_t count); 55 bool ExecutePuffDiffOperation(const InstallOperation& operation, 56 std::unique_ptr<ExtentWriter> writer, 57 FileDescriptorPtr source_fd, 58 const void* data, 59 size_t count); 60 bool ExecuteZucchiniOperation(const InstallOperation& operation, 61 std::unique_ptr<ExtentWriter> writer, 62 FileDescriptorPtr source_fd, 63 const void* data, 64 size_t count); 65 bool ExecuteLz4diffOperation(const InstallOperation& operation, 66 std::unique_ptr<ExtentWriter> writer, 67 FileDescriptorPtr source_fd, 68 const void* data, 69 size_t count); 70 71 size_t block_size_; 72 }; 73 74 } // namespace chromeos_update_engine 75 76 #endif 77