xref: /aosp_15_r20/external/bsdiff/decompressor_interface.cc (revision a3a45f308bd90ef1a6e6a5e8fb92fe449b895909)
1*a3a45f30SXin Li // Copyright 2017 The Chromium OS Authors. All rights reserved.
2*a3a45f30SXin Li // Use of this source code is governed by a BSD-style license that can be
3*a3a45f30SXin Li // found in the LICENSE file.
4*a3a45f30SXin Li 
5*a3a45f30SXin Li #include "bsdiff/decompressor_interface.h"
6*a3a45f30SXin Li 
7*a3a45f30SXin Li #include "bsdiff/brotli_decompressor.h"
8*a3a45f30SXin Li #include "bsdiff/bz2_decompressor.h"
9*a3a45f30SXin Li #include "bsdiff/logging.h"
10*a3a45f30SXin Li 
11*a3a45f30SXin Li namespace bsdiff {
12*a3a45f30SXin Li 
CreateDecompressor(CompressorType type)13*a3a45f30SXin Li std::unique_ptr<DecompressorInterface> CreateDecompressor(CompressorType type) {
14*a3a45f30SXin Li   switch (type) {
15*a3a45f30SXin Li     case CompressorType::kBZ2:
16*a3a45f30SXin Li       return std::unique_ptr<DecompressorInterface>(new BZ2Decompressor());
17*a3a45f30SXin Li     case CompressorType::kBrotli:
18*a3a45f30SXin Li       return std::unique_ptr<DecompressorInterface>(new BrotliDecompressor());
19*a3a45f30SXin Li     default:
20*a3a45f30SXin Li       LOG(ERROR) << "unsupported compressor type: "
21*a3a45f30SXin Li                  << static_cast<uint8_t>(type);
22*a3a45f30SXin Li       return nullptr;
23*a3a45f30SXin Li   }
24*a3a45f30SXin Li }
25*a3a45f30SXin Li 
26*a3a45f30SXin Li }  // namespace bsdiff
27