Chromium Code Reviews| Index: chrome/browser/component_updater/component_patcher_internal.h |
| =================================================================== |
| --- chrome/browser/component_updater/component_patcher_internal.h (revision 0) |
| +++ chrome/browser/component_updater/component_patcher_internal.h (revision 0) |
| @@ -0,0 +1,171 @@ |
| +// 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_INTERNAL_H_ |
| +#define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_INTERNAL_H_ |
| + |
| +#include <string> |
| +#include "base/basictypes.h" |
| +#include "base/files/file_path.h" |
| +#include "base/values.h" |
|
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
I am guessing the you can fwd declare Value instea
waffles
2013/06/13 20:55:04
Done.
|
| +#include "chrome/browser/component_updater/component_patcher.h" |
| + |
| +class ComponentInstaller; |
| + |
| +class DeltaUpdateOp { |
| + public: |
| + // These constants refer to the position of arguments in the command list. |
| + enum ArgumentPos { |
| + kDeltaOutputPath = 0, |
| + kDeltaOutputSha256 = 1, |
| + kDeltaOperation = 2, |
| + }; |
| + |
| + DeltaUpdateOp(); |
| + virtual ~DeltaUpdateOp(); |
| + |
| + // Parses, runs, and verifies the operation, returning an error code if an |
| + // error is encountered, and DELTA_OK otherwise. In case of errors, |
| + // extended error information can be returned in the |error| parameter. |
| + DeltaUpdateResult Run( |
| + base::ListValue* command_args, |
| + const base::FilePath& input_dir, |
| + const base::FilePath& unpack_dir, |
| + ComponentPatcher* patcher, |
| + ComponentInstaller* installer, |
| + int* error); |
| + |
| + protected: |
| + std::string output_sha256_; // The SHA-256 hash of the output file. |
| + base::FilePath output_abs_path_; // The relative location for the output. |
|
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
prefer comments above each line. In this particula
waffles
2013/06/13 20:55:04
Done.
|
| + |
| + private: |
| + DeltaUpdateResult CheckHash(); |
| + |
| + // Subclasses must override DoParseArguments to parse operation-specific |
| + // arguments. DoParseArguments returns DELTA_OK on success; any other code |
| + // represents failure. |
| + virtual DeltaUpdateResult DoParseArguments(base::ListValue* command_args, |
| + const base::FilePath& input_dir, |
| + ComponentInstaller* installer) = 0; |
| + |
| + // Subclasses must override DoRun to actually perform the patching operation. |
| + // DoRun returns DELTA_OK on success; any other code represents failure. |
| + // Additional error information can be returned in the |error| parameter. |
| + virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, int* error) = 0; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp); |
| +}; |
| + |
| +// A 'copy' operation takes a file currently residing on the disk and moves it |
| +// into the unpacking directory: this represents "no change" in the file being |
| +// installed. |
| +class DeltaUpdateOpCopy : public DeltaUpdateOp { |
| + public: |
|
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
since DeltaUpdateOp::ArgumentPos is in scope here
waffles
2013/06/13 20:55:04
Done.
|
| + enum ArgumentPos { |
| + kDeltaFrom = 3, |
| + }; |
| + |
| + DeltaUpdateOpCopy(); |
| + |
| + private: |
| + // Overrides of DeltaUpdateOp. |
| + virtual DeltaUpdateResult DoParseArguments( |
| + base::ListValue* command_args, |
| + const base::FilePath& input_dir, |
| + ComponentInstaller* installer) OVERRIDE; |
| + |
| + virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, |
| + int* error) OVERRIDE; |
| + |
| + base::FilePath input_abs_path_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCopy); |
| +}; |
| + |
| +// A 'create' operation takes a full file that was sent in the delta update |
| +// archive and moves it into the unpacking directory: this represents the |
| +// addition of a new file, or a file so different that no bandwidth could be |
| +// saved by transmitting a differential update. |
| +class DeltaUpdateOpCreate : public DeltaUpdateOp { |
| + public: |
| + enum ArgumentPos { |
| + kDeltaPatch = 3, |
| + }; |
| + |
| + DeltaUpdateOpCreate(); |
| + |
| + private: |
| + // Overrides of DeltaUpdateOp. |
| + virtual DeltaUpdateResult DoParseArguments( |
| + base::ListValue* command_args, |
| + const base::FilePath& input_dir, |
| + ComponentInstaller* installer) OVERRIDE; |
| + |
| + virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, |
| + int* error) OVERRIDE; |
| + |
| + base::FilePath patch_abs_path_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate); |
| +}; |
| + |
| +// A 'bsdiff' operation takes an existing file on disk, and a bsdiff- |
| +// format patch file provided in the delta update package, and runs bsdiff |
| +// to construct an output file in the unpacking directory. |
| +class DeltaUpdateOpPatchBsdiff : public DeltaUpdateOp { |
| + public: |
| + enum ArgumentPos { |
| + kDeltaFrom = 3, |
| + kDeltaPatch = 4, |
| + }; |
| + |
| + DeltaUpdateOpPatchBsdiff(); |
| + |
| + private: |
| + // Overrides of DeltaUpdateOp. |
| + virtual DeltaUpdateResult DoParseArguments( |
| + base::ListValue* command_args, |
| + const base::FilePath& input_dir, |
| + ComponentInstaller* installer) OVERRIDE; |
| + |
| + virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, |
| + int* error) OVERRIDE; |
| + |
| + base::FilePath patch_abs_path_; |
| + base::FilePath input_abs_path_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchBsdiff); |
| +}; |
| + |
| +// A 'courgette' operation takes an existing file on disk, and a Courgette- |
| +// format patch file provided in the delta update package, and runs Courgette |
| +// to construct an output file in the unpacking directory. |
| +class DeltaUpdateOpPatchCourgette : public DeltaUpdateOp { |
| + public: |
| + enum ArgumentPos { |
| + kDeltaFrom = 3, |
| + kDeltaPatch = 4, |
| + }; |
| + |
| + DeltaUpdateOpPatchCourgette(); |
| + |
| + private: |
| + // Overrides of DeltaUpdateOp. |
| + virtual DeltaUpdateResult DoParseArguments( |
| + base::ListValue* command_args, |
| + const base::FilePath& input_dir, |
| + ComponentInstaller* installer) OVERRIDE; |
| + |
| + virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, |
| + int* error) OVERRIDE; |
| + |
| + base::FilePath patch_abs_path_; |
| + base::FilePath input_abs_path_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchCourgette); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_INTERNAL_H_ |
| + |