OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium 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 CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/component_updater/component_unpacker.h" |
| 11 |
| 12 namespace base { |
| 13 class FilePath; |
| 14 } |
| 15 |
| 16 class ComponentInstaller; |
| 17 |
| 18 // Applies a delta patch to a file. Specifically, creates a file at |
| 19 // |output_file| using |input_file| patched according to the algorithm |
| 20 // specified by |patch_type| using |patch_file|. Sets the value of error to |
| 21 // the error code of the failing patch operation, if there is such a failure. |
| 22 class ComponentPatcher { |
| 23 public: |
| 24 // The type of a patch file. |
| 25 enum PatchType { |
| 26 kPatchTypeUnknown, |
| 27 kPatchTypeCourgette, |
| 28 kPatchTypeBsdiff, |
| 29 }; |
| 30 |
| 31 ComponentPatcher() {} |
| 32 virtual ComponentUnpacker::Error Patch(PatchType patch_type, |
| 33 const base::FilePath& input_file, |
| 34 const base::FilePath& patch_file, |
| 35 const base::FilePath& output_file, |
| 36 int* error) = 0; |
| 37 virtual ~ComponentPatcher() {} |
| 38 }; |
| 39 |
| 40 class ComponentPatcherCrossPlatform : public ComponentPatcher { |
| 41 public: |
| 42 ComponentPatcherCrossPlatform(); |
| 43 virtual ComponentUnpacker::Error Patch(PatchType patch_type, |
| 44 const base::FilePath& input_file, |
| 45 const base::FilePath& patch_file, |
| 46 const base::FilePath& output_file, |
| 47 int* error) OVERRIDE; |
| 48 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); |
| 50 }; |
| 51 |
| 52 // Recreates the content of a full CRX by taking the unpacked files of a |
| 53 // differential component update in |input_dir| and patching the installed |
| 54 // component files. |
| 55 // The resulting files are written into the |unpack_dir| directory. |
| 56 ComponentUnpacker::Error DifferentialUpdatePatch( |
| 57 const base::FilePath& input_dir, |
| 58 const base::FilePath& unpack_dir, |
| 59 ComponentPatcher* component_patcher, |
| 60 ComponentInstaller* installer, |
| 61 int* error); |
| 62 |
| 63 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
OLD | NEW |