| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Component updates can be either differential updates or full updates. | 5 // Component updates can be either differential updates or full updates. |
| 6 // Full updates come in CRX format; differential updates come in CRX-style | 6 // Full updates come in CRX format; differential updates come in CRX-style |
| 7 // archives, but have a different magic number. They contain "commands.json", a | 7 // archives, but have a different magic number. They contain "commands.json", a |
| 8 // list of commands for the patcher to follow. The patcher uses these commands, | 8 // list of commands for the patcher to follow. The patcher uses these commands, |
| 9 // the other files in the archive, and the files from the existing installation | 9 // the other files in the archive, and the files from the existing installation |
| 10 // of the component to create the contents of a full update, which is then | 10 // of the component to create the contents of a full update, which is then |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // the error code of the failing patch operation, if there is such a failure. | 44 // the error code of the failing patch operation, if there is such a failure. |
| 45 class ComponentPatcher { | 45 class ComponentPatcher { |
| 46 public: | 46 public: |
| 47 // The type of a patch file. | 47 // The type of a patch file. |
| 48 enum PatchType { | 48 enum PatchType { |
| 49 kPatchTypeUnknown, | 49 kPatchTypeUnknown, |
| 50 kPatchTypeCourgette, | 50 kPatchTypeCourgette, |
| 51 kPatchTypeBsdiff, | 51 kPatchTypeBsdiff, |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 virtual ComponentUnpacker::Error Patch(PatchType patch_type, | 54 virtual component_updater::Error Patch(PatchType patch_type, |
| 55 const base::FilePath& input_file, | 55 const base::FilePath& input_file, |
| 56 const base::FilePath& patch_file, | 56 const base::FilePath& patch_file, |
| 57 const base::FilePath& output_file, | 57 const base::FilePath& output_file, |
| 58 int* error) = 0; | 58 int* error) = 0; |
| 59 virtual ~ComponentPatcher() {} | 59 virtual ~ComponentPatcher() {} |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class ComponentPatcherCrossPlatform : public ComponentPatcher { | 62 class ComponentPatcherCrossPlatform : public ComponentPatcher { |
| 63 public: | 63 public: |
| 64 ComponentPatcherCrossPlatform(); | 64 ComponentPatcherCrossPlatform(); |
| 65 virtual ComponentUnpacker::Error Patch(PatchType patch_type, | 65 virtual component_updater::Error Patch(PatchType patch_type, |
| 66 const base::FilePath& input_file, | 66 const base::FilePath& input_file, |
| 67 const base::FilePath& patch_file, | 67 const base::FilePath& patch_file, |
| 68 const base::FilePath& output_file, | 68 const base::FilePath& output_file, |
| 69 int* error) OVERRIDE; | 69 int* error) OVERRIDE; |
| 70 private: | 70 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); | 71 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // This function takes an unpacked differential CRX (|input_dir|) and a | 74 // This function takes an unpacked differential CRX (|input_dir|) and a |
| 75 // component installer, and creates a new (non-differential) unpacked CRX, which | 75 // component installer, and creates a new (non-differential) unpacked CRX, which |
| 76 // is then installed normally. | 76 // is then installed normally. |
| 77 // The non-differential files are written into the |unpack_dir| directory. | 77 // The non-differential files are written into the |unpack_dir| directory. |
| 78 // Sets |error| to the error code of the first failing patch operation. | 78 // When finished, calls the callback, passing error codes if any errors were |
| 79 ComponentUnpacker::Error DifferentialUpdatePatch( | 79 // encountered. |
| 80 void DifferentialUpdatePatch( |
| 80 const base::FilePath& input_dir, | 81 const base::FilePath& input_dir, |
| 81 const base::FilePath& unpack_dir, | 82 const base::FilePath& unpack_dir, |
| 82 ComponentPatcher* component_patcher, | 83 ComponentPatcher* component_patcher, |
| 83 ComponentInstaller* installer, | 84 ComponentInstaller* installer, |
| 84 int* error); | 85 base::Callback<void(component_updater::Error, int)> callback); |
| 85 | 86 |
| 86 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ | 87 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
| OLD | NEW |