1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
6 #define COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
7 
8 #include "components/zucchini/image_utils.h"
9 #include "components/zucchini/patch_reader.h"
10 #include "components/zucchini/zucchini.h"
11 
12 namespace zucchini {
13 
14 // Reads equivalences from |patch_reader| to form preliminary |new_image|,
15 // copying regions from |old_image| and writing extra data from |patch_reader|.
16 bool ApplyEquivalenceAndExtraData(ConstBufferView old_image,
17                                   const PatchElementReader& patch_reader,
18                                   MutableBufferView new_image);
19 
20 // Reads raw delta from |patch_reader| and applies corrections to |new_image|.
21 bool ApplyRawDelta(const PatchElementReader& patch_reader,
22                    MutableBufferView new_image);
23 
24 // Corrects references in |new_image| by projecting references from |old_image|
25 // and applying corrections from |patch_reader|. Both |old_image| and
26 // |new_image| are matching elements associated with |exe_type|.
27 bool ApplyReferencesCorrection(ExecutableType exe_type,
28                                ConstBufferView old_image,
29                                const PatchElementReader& patch_reader,
30                                MutableBufferView new_image);
31 
32 // Applies patch element with type |exe_type| from |patch_reader| on |old_image|
33 // to produce |new_image|.
34 bool ApplyElement(ExecutableType exe_type,
35                   ConstBufferView old_image,
36                   const PatchElementReader& patch_reader,
37                   MutableBufferView new_image);
38 
39 }  // namespace zucchini
40 
41 #endif  // COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
42