blob: d65ac4a5d9c7470268bf41c4b64046e15b86e273 [file] [log] [blame]
Kelvin Zhang94f51cc2020-09-25 11:34:49 -04001//
2// Copyright (C) 2020 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_VABC_PARTITION_WRITER_H_
18#define UPDATE_ENGINE_VABC_PARTITION_WRITER_H_
19
20#include <memory>
21
Kelvin Zhang9b10dba2020-09-25 17:09:11 -040022#include <libsnapshot/snapshot_writer.h>
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040023
24#include "update_engine/payload_consumer/install_plan.h"
25#include "update_engine/payload_consumer/partition_writer.h"
26
27namespace chromeos_update_engine {
28class VABCPartitionWriter final : public PartitionWriter {
29 public:
30 using PartitionWriter::PartitionWriter;
31 [[nodiscard]] bool Init(const InstallPlan* install_plan,
32 bool source_may_exist) override;
33 ~VABCPartitionWriter() override;
34
35 [[nodiscard]] std::unique_ptr<ExtentWriter> CreateBaseExtentWriter() override;
36
37 // Only ZERO and SOURCE_COPY InstallOperations are treated special by VABC
38 // Partition Writer. These operations correspond to COW_ZERO and COW_COPY. All
39 // other operations just get converted to COW_REPLACE.
40 [[nodiscard]] bool PerformZeroOrDiscardOperation(
41 const InstallOperation& operation) override;
42 [[nodiscard]] bool PerformSourceCopyOperation(
43 const InstallOperation& operation, ErrorCode* error) override;
Kelvin Zhang9b10dba2020-09-25 17:09:11 -040044 [[nodiscard]] bool Flush() override;
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040045
46 private:
Kelvin Zhang9b10dba2020-09-25 17:09:11 -040047 std::unique_ptr<android::snapshot::ISnapshotWriter> cow_writer_;
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040048};
49
50} // namespace chromeos_update_engine
51
52#endif