Index: chrome/browser/component_updater/component_patcher.h |
=================================================================== |
--- chrome/browser/component_updater/component_patcher.h (revision 0) |
+++ chrome/browser/component_updater/component_patcher.h (revision 0) |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
+#define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/files/file_path.h" |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
I am guessing you can forward declare FilePath her
waffles
2013/06/13 20:55:04
Done.
|
+ |
+class ComponentInstaller; |
+ |
+enum DeltaUpdateResult { |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
while the all caps constants in enums is a valid s
waffles
2013/06/13 20:55:04
Done. We've unified this with the unpacker error c
|
+ // Indicates success. |
+ DELTA_OK, |
+ |
+ // Either the file doesn't exist or the expected hash is invalid. |
+ DELTA_VERIFICATION_INPUT_ERROR, |
+ |
+ // The expected hash and the actual hash don't match. |
+ DELTA_VERIFICATION_FAILURE, |
+ |
+ // commands.json is malformed, or references files that don't exist. |
+ DELTA_BAD_COMMANDS, |
+ |
+ // commands.json contains an unsupported command. |
+ DELTA_UNSUPPORTED_COMMAND, |
+ |
+ // There was a generic I/O error. |
+ DELTA_IO_ERROR, |
+ |
+ // The operation (courgette/bsdiff/move/...) failed. |
+ DELTA_OPERATION_FAILURE, |
+ |
+ // The process which runs Courgette failed to start or the exit code of |
+ // the process could not be retrieved. |
+ DELTA_PATCH_PROCESS_FAILURE, |
+}; |
+ |
+// The type of a patch file. |
+enum PatchType { |
+ PATCH_TYPE_UNKNOWN, |
+ PATCH_TYPE_COURGETTE, |
+ PATCH_TYPE_BSDIFF, |
+}; |
+ |
+// Applies a delta patch to a file. |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
we can beef a bit this description, like explainin
waffles
2013/06/13 20:55:04
Done.
|
+class ComponentPatcher { |
+ public: |
+ ComponentPatcher() {} |
+ virtual DeltaUpdateResult Patch(PatchType patch_type, |
+ const base::FilePath& input_file, |
+ const base::FilePath& patch_file, |
+ const base::FilePath& output_file, |
+ int* error) = 0; |
+ virtual ~ComponentPatcher() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ComponentPatcher); |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
abstract base classes we normally don't put DISALL
waffles
2013/06/13 20:55:04
Done.
|
+}; |
+ |
+class ComponentPatcherCrossPlatform : public ComponentPatcher { |
+ public: |
+ ComponentPatcherCrossPlatform(); |
+ virtual DeltaUpdateResult Patch(PatchType patch_type, |
+ const base::FilePath& input_file, |
+ const base::FilePath& patch_file, |
+ const base::FilePath& output_file, |
+ int* error) OVERRIDE; |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
use of override macro might require the compiler_s
waffles
2013/06/13 20:55:04
Done.
|
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); |
+}; |
+ |
+// Recreates the content of a full CRX by taking the unpacked files of a |
+// differential component update in |input_dir| and patching the installed |
+// component files. |
+// The resulting files are written into the |unpack_dir| directory. |
+DeltaUpdateResult DifferentialUpdatePatch(const base::FilePath& input_dir, |
+ const base::FilePath& unpack_dir, |
+ ComponentPatcher* component_patcher, |
+ ComponentInstaller* installer, |
+ int* error); |
+ |
+#endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |