OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Implementation of the byte-level differential compression used internally by | 5 // Implementation of the byte-level differential compression used internally by |
6 // Courgette. | 6 // Courgette. |
7 | 7 |
8 #include "courgette/simple_delta.h" | 8 #include "courgette/simple_delta.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 | 11 |
12 #include "courgette/third_party/bsdiff/bsdiff.h" | 12 #include "courgette/third_party/bsdiff/bsdiff.h" |
13 | 13 |
14 namespace courgette { | 14 namespace courgette { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 Status BSDiffStatusToStatus(BSDiffStatus status) { | 18 Status BSDiffStatusToStatus(bsdiff::BSDiffStatus status) { |
19 switch (status) { | 19 switch (status) { |
20 case OK: return C_OK; | 20 case bsdiff::OK: return C_OK; |
21 case CRC_ERROR: return C_BINARY_DIFF_CRC_ERROR; | 21 case bsdiff::CRC_ERROR: return C_BINARY_DIFF_CRC_ERROR; |
22 default: return C_GENERAL_ERROR; | 22 default: return C_GENERAL_ERROR; |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 } | 26 } |
27 | 27 |
28 Status ApplySimpleDelta(SourceStream* old, SourceStream* delta, | 28 Status ApplySimpleDelta(SourceStream* old, SourceStream* delta, |
29 SinkStream* target) { | 29 SinkStream* target) { |
30 return BSDiffStatusToStatus(ApplyBinaryPatch(old, delta, target)); | 30 return BSDiffStatusToStatus(bsdiff::ApplyBinaryPatch(old, delta, target)); |
31 } | 31 } |
32 | 32 |
33 Status GenerateSimpleDelta(SourceStream* old, SourceStream* target, | 33 Status GenerateSimpleDelta(SourceStream* old, SourceStream* target, |
34 SinkStream* delta) { | 34 SinkStream* delta) { |
35 VLOG(1) << "GenerateSimpleDelta " << old->Remaining() | 35 VLOG(1) << "GenerateSimpleDelta " << old->Remaining() |
36 << " " << target->Remaining(); | 36 << " " << target->Remaining(); |
37 return BSDiffStatusToStatus(CreateBinaryPatch(old, target, delta)); | 37 return BSDiffStatusToStatus(bsdiff::CreateBinaryPatch(old, target, delta)); |
38 } | 38 } |
39 | 39 |
40 } // namespace courgette | 40 } // namespace courgette |
OLD | NEW |