blob: 6c84fafa56530257546b9e5c0b6d4fb30e620712 [file] [log] [blame]
Kelvin Zhang40d96662021-02-24 14:21:29 -05001//
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
26namespace chromeos_update_engine {
27
28class InstallOperationExecutor {
29 public:
30 explicit InstallOperationExecutor(size_t block_size)
31 : block_size_(block_size) {}
32
Kelvin Zhang40d96662021-02-24 14:21:29 -050033 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 Zhang23dfcd22021-08-31 16:32:49 -070038 std::unique_ptr<ExtentWriter> writer);
Kelvin Zhang40d96662021-02-24 14:21:29 -050039 bool ExecuteSourceCopyOperation(const InstallOperation& operation,
Kelvin Zhang23dfcd22021-08-31 16:32:49 -070040 std::unique_ptr<ExtentWriter> writer,
Kelvin Zhang40d96662021-02-24 14:21:29 -050041 FileDescriptorPtr source_fd);
Tianjie8e0090d2021-08-30 22:35:21 -070042
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 Zhang40d96662021-02-24 14:21:29 -050050 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);
Tianjie8e0090d2021-08-30 22:35:21 -070060 bool ExecuteZucchiniOperation(const InstallOperation& operation,
61 std::unique_ptr<ExtentWriter> writer,
62 FileDescriptorPtr source_fd,
63 const void* data,
64 size_t count);
Kelvin Zhangcb2dc882021-11-22 09:26:50 -080065 bool ExecuteLz4diffOperation(const InstallOperation& operation,
66 std::unique_ptr<ExtentWriter> writer,
67 FileDescriptorPtr source_fd,
68 const void* data,
69 size_t count);
Kelvin Zhang40d96662021-02-24 14:21:29 -050070
Kelvin Zhang40d96662021-02-24 14:21:29 -050071 size_t block_size_;
72};
73
74} // namespace chromeos_update_engine
75
76#endif