Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 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: |
| 30 | explicit InstallOperationExecutor(size_t block_size) |
| 31 | : block_size_(block_size) {} |
| 32 | |
Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 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, |
Kelvin Zhang | 23dfcd2 | 2021-08-31 16:32:49 -0700 | [diff] [blame] | 38 | std::unique_ptr<ExtentWriter> writer); |
Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 39 | bool ExecuteSourceCopyOperation(const InstallOperation& operation, |
Kelvin Zhang | 23dfcd2 | 2021-08-31 16:32:49 -0700 | [diff] [blame] | 40 | std::unique_ptr<ExtentWriter> writer, |
Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 41 | FileDescriptorPtr source_fd); |
Tianjie | 8e0090d | 2021-08-30 22:35:21 -0700 | [diff] [blame] | 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: |
Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 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); |
Tianjie | 8e0090d | 2021-08-30 22:35:21 -0700 | [diff] [blame] | 60 | bool ExecuteZucchiniOperation(const InstallOperation& operation, |
| 61 | std::unique_ptr<ExtentWriter> writer, |
| 62 | FileDescriptorPtr source_fd, |
| 63 | const void* data, |
| 64 | size_t count); |
Kelvin Zhang | cb2dc88 | 2021-11-22 09:26:50 -0800 | [diff] [blame] | 65 | bool ExecuteLz4diffOperation(const InstallOperation& operation, |
| 66 | std::unique_ptr<ExtentWriter> writer, |
| 67 | FileDescriptorPtr source_fd, |
| 68 | const void* data, |
| 69 | size_t count); |
Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 70 | |
Kelvin Zhang | 40d9666 | 2021-02-24 14:21:29 -0500 | [diff] [blame] | 71 | size_t block_size_; |
| 72 | }; |
| 73 | |
| 74 | } // namespace chromeos_update_engine |
| 75 | |
| 76 | #endif |