• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SRC_INCLUDE_PUFFIN_PUFFDIFF_H_
6 #define SRC_INCLUDE_PUFFIN_PUFFDIFF_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "bsdiff/constants.h"
12 
13 #include "puffin/common.h"
14 #include "puffin/stream.h"
15 
16 namespace puffin {
17 
18 // Performs a diff operation between input deflate streams and creates a patch
19 // that is used in the client to recreate the |dst| from |src|.
20 // |src|          IN   Source deflate stream.
21 // |dst|          IN   Destination deflate stream.
22 // |src_deflates| IN   Deflate locations in |src|.
23 // |dst_deflates| IN   Deflate locations in |dst|.
24 // |compressors|  IN   Compressors to use in the underlying bsdiff, e.g. bz2,
25 //                     brotli.
26 // |tmp_filepath| IN   A path to a temporary file. The caller has the
27 //                     responsibility of unlinking the file after the call to
28 //                     |PuffDiff| finishes.
29 // |puffin_patch| OUT  The patch that later can be used in |PuffPatch|.
30 bool PuffDiff(UniqueStreamPtr src,
31               UniqueStreamPtr dst,
32               const std::vector<BitExtent>& src_deflates,
33               const std::vector<BitExtent>& dst_deflates,
34               const std::vector<bsdiff::CompressorType>& compressors,
35               const std::string& tmp_filepath,
36               Buffer* patch);
37 
38 // Similar to the function above, except that it accepts raw buffer rather than
39 // stream.
40 bool PuffDiff(const Buffer& src,
41               const Buffer& dst,
42               const std::vector<BitExtent>& src_deflates,
43               const std::vector<BitExtent>& dst_deflates,
44               const std::vector<bsdiff::CompressorType>& compressors,
45               const std::string& tmp_filepath,
46               Buffer* patch);
47 
48 // The default puffdiff function that uses both bz2 and brotli to compress the
49 // patch data.
50 bool PuffDiff(const Buffer& src,
51               const Buffer& dst,
52               const std::vector<BitExtent>& src_deflates,
53               const std::vector<BitExtent>& dst_deflates,
54               const std::string& tmp_filepath,
55               Buffer* patch);
56 
57 }  // namespace puffin
58 
59 #endif  // SRC_INCLUDE_PUFFIN_PUFFDIFF_H_
60