Alex Deymo | 8a179e5 | 2017-10-26 17:10:20 +0200 | [diff] [blame] | 1 | // Copyright 2017 The Chromium OS 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 | #include "bsdiff/patch_writer_factory.h" |
| 6 | |
Alex Deymo | 710b3da | 2017-10-26 13:13:28 +0200 | [diff] [blame] | 7 | #include "bsdiff/endsley_patch_writer.h" |
Alex Deymo | 8a179e5 | 2017-10-26 17:10:20 +0200 | [diff] [blame] | 8 | #include "bsdiff/patch_writer.h" |
| 9 | |
| 10 | namespace bsdiff { |
| 11 | |
| 12 | std::unique_ptr<PatchWriterInterface> CreateBsdiffPatchWriter( |
| 13 | const std::string& patch_filename) { |
| 14 | return std::unique_ptr<PatchWriterInterface>( |
Tianjie Xu | 1f1cdb2 | 2017-11-20 11:05:55 -0800 | [diff] [blame] | 15 | new BsdiffPatchWriter(patch_filename)); |
| 16 | } |
| 17 | |
| 18 | std::unique_ptr<PatchWriterInterface> CreateBSDF2PatchWriter( |
| 19 | const std::string& patch_filename, |
| 20 | CompressorType type, |
Tianjie Xu | 2e70b55 | 2018-03-02 16:22:10 -0800 | [diff] [blame] | 21 | int brotli_quality) { |
Tianjie Xu | 77833b6 | 2018-03-07 18:13:47 -0800 | [diff] [blame] | 22 | return CreateBSDF2PatchWriter( |
| 23 | patch_filename, std::vector<CompressorType>{type}, brotli_quality); |
| 24 | } |
| 25 | |
| 26 | std::unique_ptr<PatchWriterInterface> CreateBSDF2PatchWriter( |
| 27 | const std::string& patch_filename, |
| 28 | const std::vector<CompressorType>& types, |
| 29 | int brotli_quality) { |
Tianjie Xu | 1f1cdb2 | 2017-11-20 11:05:55 -0800 | [diff] [blame] | 30 | return std::unique_ptr<PatchWriterInterface>( |
Tianjie Xu | 77833b6 | 2018-03-07 18:13:47 -0800 | [diff] [blame] | 31 | new BsdiffPatchWriter(patch_filename, types, brotli_quality)); |
Alex Deymo | 8a179e5 | 2017-10-26 17:10:20 +0200 | [diff] [blame] | 32 | } |
| 33 | |
Alex Deymo | 710b3da | 2017-10-26 13:13:28 +0200 | [diff] [blame] | 34 | std::unique_ptr<PatchWriterInterface> CreateEndsleyPatchWriter( |
Alex Deymo | 19fc575 | 2018-02-15 16:56:39 +0100 | [diff] [blame] | 35 | std::vector<uint8_t>* patch, |
| 36 | CompressorType type, |
Tianjie Xu | 2e70b55 | 2018-03-02 16:22:10 -0800 | [diff] [blame] | 37 | int brotli_quality) { |
Alex Deymo | 19fc575 | 2018-02-15 16:56:39 +0100 | [diff] [blame] | 38 | return std::unique_ptr<PatchWriterInterface>( |
Tianjie Xu | 2e70b55 | 2018-03-02 16:22:10 -0800 | [diff] [blame] | 39 | new EndsleyPatchWriter(patch, type, brotli_quality)); |
Alex Deymo | 19fc575 | 2018-02-15 16:56:39 +0100 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | std::unique_ptr<PatchWriterInterface> CreateEndsleyPatchWriter( |
Alex Deymo | 710b3da | 2017-10-26 13:13:28 +0200 | [diff] [blame] | 43 | std::vector<uint8_t>* patch) { |
Alex Deymo | 19fc575 | 2018-02-15 16:56:39 +0100 | [diff] [blame] | 44 | return std::unique_ptr<PatchWriterInterface>( |
| 45 | new EndsleyPatchWriter(patch, CompressorType::kNoCompression, 0)); |
Alex Deymo | 710b3da | 2017-10-26 13:13:28 +0200 | [diff] [blame] | 46 | } |
| 47 | |
Alex Deymo | 8a179e5 | 2017-10-26 17:10:20 +0200 | [diff] [blame] | 48 | } // namespace bsdiff |