blob: 034fb57afe26dbb790d2050a64a5222bcc7fe614 [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
22#include <libsnapshot/cow_writer.h>
23
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;
44
45 private:
46 std::unique_ptr<android::snapshot::ICowWriter> cow_writer_;
47};
48
49} // namespace chromeos_update_engine
50
51#endif