Tianjie Xu | 4d10c3e | 2017-10-26 14:02:06 -0700 | [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/decompressor_interface.h" |
| 6 | |
| 7 | #include "bsdiff/brotli_decompressor.h" |
| 8 | #include "bsdiff/bz2_decompressor.h" |
Tianjie Xu | b4cba64 | 2017-11-14 22:46:38 -0800 | [diff] [blame] | 9 | #include "bsdiff/logging.h" |
Tianjie Xu | 4d10c3e | 2017-10-26 14:02:06 -0700 | [diff] [blame] | 10 | |
| 11 | namespace bsdiff { |
| 12 | |
| 13 | std::unique_ptr<DecompressorInterface> CreateDecompressor(CompressorType type) { |
Tianjie Xu | b4cba64 | 2017-11-14 22:46:38 -0800 | [diff] [blame] | 14 | 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 Xu | 18480eb | 2017-11-29 16:21:43 -0800 | [diff] [blame] | 21 | << static_cast<uint8_t>(type); |
Tianjie Xu | b4cba64 | 2017-11-14 22:46:38 -0800 | [diff] [blame] | 22 | return nullptr; |
Tianjie Xu | 4d10c3e | 2017-10-26 14:02:06 -0700 | [diff] [blame] | 23 | } |
Tianjie Xu | 4d10c3e | 2017-10-26 14:02:06 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Alex Deymo | 9bb4ddb | 2018-02-14 16:30:54 +0100 | [diff] [blame] | 26 | } // namespace bsdiff |