blob: d8ebb5730b7e488396f5b20397a3ddb7ee19372c [file] [log] [blame]
Tianjie Xu4d10c3e2017-10-26 14:02:06 -07001// 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/decompressor_interface.h"
6
7#include "bsdiff/brotli_decompressor.h"
8#include "bsdiff/bz2_decompressor.h"
Tianjie Xub4cba642017-11-14 22:46:38 -08009#include "bsdiff/logging.h"
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070010
11namespace bsdiff {
12
13std::unique_ptr<DecompressorInterface> CreateDecompressor(CompressorType type) {
Tianjie Xub4cba642017-11-14 22:46:38 -080014 switch (type) {
15 case CompressorType::kBZ2:
16 return std::unique_ptr<DecompressorInterface>(new BZ2Decompressor());
17 case CompressorType::kBrotli:
18 return std::unique_ptr<DecompressorInterface>(new BrotliDecompressor());
19 default:
20 LOG(ERROR) << "unsupported compressor type: "
Tianjie Xu18480eb2017-11-29 16:21:43 -080021 << static_cast<uint8_t>(type);
Tianjie Xub4cba642017-11-14 22:46:38 -080022 return nullptr;
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070023 }
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070024}
25
Alex Deymo9bb4ddb2018-02-14 16:30:54 +010026} // namespace bsdiff