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 #ifndef _BSDIFF_PATCH_WRITER_FACTORY_H_ 6 #define _BSDIFF_PATCH_WRITER_FACTORY_H_ 7 8 #include <memory> 9 #include <string> 10 #include <vector> 11 12 #include "bsdiff/common.h" 13 #include "bsdiff/constants.h" 14 #include "bsdiff/patch_writer_interface.h" 15 16 namespace bsdiff { 17 18 // Create a patch writer compatible with upstream's "BSDIFF40" patch format 19 // using bz2 as a compressor. 20 BSDIFF_EXPORT 21 std::unique_ptr<PatchWriterInterface> CreateBsdiffPatchWriter( 22 const std::string& patch_filename); 23 24 // Create a patch writer using the "BSDF2" patch format. It uses the compressor 25 // specified in |type|. And the brotli compressor will have the compression 26 // quality |brotli_quality|. 27 BSDIFF_EXPORT 28 std::unique_ptr<PatchWriterInterface> CreateBSDF2PatchWriter( 29 const std::string& patch_filename, 30 CompressorType type, 31 int brotli_quality); 32 33 // Create a patch writer using the "BSDF2" patch format. It also tries all the 34 // compressors in |types| to generate the smallest patch. 35 BSDIFF_EXPORT 36 std::unique_ptr<PatchWriterInterface> CreateBSDF2PatchWriter( 37 const std::string& patch_filename, 38 const std::vector<CompressorType>& types, 39 int brotli_quality); 40 41 // Create a patch writer compatible with Android Play Store bsdiff patches. 42 // The data will be written to the passed |patch| vector, which must be valid 43 // until Close() is called or this patch is destroyed. The data will be 44 // compressed using the compressor type |type|. To get an uncompressed patch, 45 // pass CompressortType::kNoCompression. 46 BSDIFF_EXPORT 47 std::unique_ptr<PatchWriterInterface> CreateEndsleyPatchWriter( 48 std::vector<uint8_t>* patch, 49 CompressorType type, 50 int brotli_quality); 51 52 // Helper function to create an Endsley patch writer with no compression. 53 BSDIFF_EXPORT 54 std::unique_ptr<PatchWriterInterface> CreateEndsleyPatchWriter( 55 std::vector<uint8_t>* patch); 56 57 58 } // namespace bsdiff 59 60 #endif // _BSDIFF_PATCH_WRITER_FACTORY_H_ 61