Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 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 <vector> |
| 9 | |
| 10 | #include "components/zucchini/image_utils.h" |
| 11 | #include "components/zucchini/patch_reader.h" |
| 12 | #include "components/zucchini/zucchini.h" |
| 13 | |
| 14 | namespace zucchini { |
| 15 | |
| 16 | // Reads equivalences from |patch_reader| to form preliminary |new_image|, |
| 17 | // copying regions from |old_image| and writing extra data from |patch_reader|. |
| 18 | bool ApplyEquivalenceAndExtraData(ConstBufferView old_image, |
| 19 | const PatchElementReader& patch_reader, |
| 20 | MutableBufferView new_image); |
| 21 | |
| 22 | // Reads raw delta from |patch_reader| and applies corrections to |new_image|. |
| 23 | bool ApplyRawDelta(const PatchElementReader& patch_reader, |
| 24 | MutableBufferView new_image); |
| 25 | |
| 26 | // Corrects references in |new_image| by projecting references from |old_image| |
| 27 | // and applying corrections from |patch_reader|. Both |old_image| and |
| 28 | // |new_image| are matching elements associated with |exe_type|. |
| 29 | bool ApplyReferencesCorrection(ExecutableType exe_type, |
| 30 | ConstBufferView old_image, |
| 31 | const PatchElementReader& patch_reader, |
| 32 | MutableBufferView new_image); |
| 33 | |
| 34 | // Applies patch element with type |exe_type| from |patch_reader| on |old_image| |
| 35 | // to produce |new_image|. |
| 36 | bool ApplyElement(ExecutableType exe_type, |
| 37 | ConstBufferView old_image, |
| 38 | const PatchElementReader& patch_reader, |
| 39 | MutableBufferView new_image); |
| 40 | |
| 41 | } // namespace zucchini |
| 42 | |
| 43 | #endif // COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_ |