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
7 #include "bsdiff/endsley_patch_writer.h"
8 #include "bsdiff/patch_writer.h"
9
10 namespace bsdiff {
11
CreateBsdiffPatchWriter(const std::string & patch_filename)12 std::unique_ptr<PatchWriterInterface> CreateBsdiffPatchWriter(
13 const std::string& patch_filename) {
14 return std::unique_ptr<PatchWriterInterface>(
15 new BsdiffPatchWriter(patch_filename));
16 }
17
CreateBSDF2PatchWriter(const std::string & patch_filename,CompressorType type,int brotli_quality)18 std::unique_ptr<PatchWriterInterface> CreateBSDF2PatchWriter(
19 const std::string& patch_filename,
20 CompressorType type,
21 int brotli_quality) {
22 return CreateBSDF2PatchWriter(
23 patch_filename, std::vector<CompressorType>{type}, brotli_quality);
24 }
25
CreateBSDF2PatchWriter(const std::string & patch_filename,const std::vector<CompressorType> & types,int brotli_quality)26 std::unique_ptr<PatchWriterInterface> CreateBSDF2PatchWriter(
27 const std::string& patch_filename,
28 const std::vector<CompressorType>& types,
29 int brotli_quality) {
30 return std::unique_ptr<PatchWriterInterface>(
31 new BsdiffPatchWriter(patch_filename, types, brotli_quality));
32 }
33
CreateEndsleyPatchWriter(std::vector<uint8_t> * patch,CompressorType type,int brotli_quality)34 std::unique_ptr<PatchWriterInterface> CreateEndsleyPatchWriter(
35 std::vector<uint8_t>* patch,
36 CompressorType type,
37 int brotli_quality) {
38 return std::unique_ptr<PatchWriterInterface>(
39 new EndsleyPatchWriter(patch, type, brotli_quality));
40 }
41
CreateEndsleyPatchWriter(std::vector<uint8_t> * patch)42 std::unique_ptr<PatchWriterInterface> CreateEndsleyPatchWriter(
43 std::vector<uint8_t>* patch) {
44 return std::unique_ptr<PatchWriterInterface>(
45 new EndsleyPatchWriter(patch, CompressorType::kNoCompression, 0));
46 }
47
48 } // namespace bsdiff
49