Chromium Code Reviews| Index: chrome/installer/setup/setup_util.cc |
| diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc |
| index ef0f836039beefc75af561bc93b24801e9771385..eeb1f8be27b5e2c38909352e77d7015cfa789175 100644 |
| --- a/chrome/installer/setup/setup_util.cc |
| +++ b/chrome/installer/setup/setup_util.cc |
| @@ -24,12 +24,19 @@ |
| #include "chrome/installer/util/util_constants.h" |
| #include "chrome/installer/util/work_item.h" |
| #include "courgette/courgette.h" |
| +#include "courgette/third_party/bsdiff.h" |
| #include "third_party/bspatch/mbspatch.h" |
| namespace installer { |
| namespace { |
| +// The range of error values for the installer, Courgette, and bsdiff is |
| +// overlapping. These offset values disambiguate between different sets |
| +// of errors by shifting the values up with the specified offset. |
| +const int kCourgetteErrorOffset = 300; |
| +const int kBsdiffErrorOffset = 600; |
|
robertshield
2013/06/17 16:39:28
This now defines part of the contract for setup.ex
Sorin Jianu
2013/06/17 22:21:09
Done.
|
| + |
| // Launches |setup_exe| with |command_line|, save --install-archive and its |
| // value if present. Returns false if the process failed to launch. Otherwise, |
| // waits indefinitely for it to exit and populates |exit_code| as expected. On |
| @@ -86,6 +93,51 @@ bool SupportsSingleInstall(BrowserDistribution::Type type) { |
| } // namespace |
| +int CourgettePatchFiles(const base::FilePath& src, |
| + const base::FilePath& patch, |
| + const base::FilePath& dest) { |
| + VLOG(1) << "Applying Courgette patch " << patch.value() << " to file " |
| + << src.value() << " and generating file " << dest.value(); |
| + |
| + if (src.empty() || patch.empty() || dest.empty()) { |
| + return installer::PATCH_INVALID_ARGUMENTS; |
| + } |
| + |
| + const courgette::Status patch_status = |
| + courgette::ApplyEnsemblePatch(src.value().c_str(), |
| + patch.value().c_str(), |
| + dest.value().c_str()); |
| + const int exit_code = (patch_status != courgette::C_OK) ? |
| + static_cast<int>(patch_status) + kCourgetteErrorOffset : 0; |
|
robertshield
2013/06/17 16:39:28
nit: only one space before :
Sorin Jianu
2013/06/17 22:21:09
Done.
|
| + if (exit_code) { |
| + VLOG(1) << "Failed to apply patch " << patch.value() |
| + << ". err=" << exit_code; |
| + } |
| + |
| + return exit_code; |
| +} |
| + |
| +int BsdiffPatchFiles(const base::FilePath& src, |
| + const base::FilePath& patch, |
| + const base::FilePath& dest) { |
| + VLOG(1) << "Applying bsdiff patch " << patch.value() << " to file " |
| + << src.value() << " and generating file " << dest.value(); |
| + |
| + if (src.empty() || patch.empty() || dest.empty()) { |
| + return installer::PATCH_INVALID_ARGUMENTS; |
| + } |
| + |
| + const int patch_status = courgette::ApplyBinaryPatch(src, patch, dest); |
| + const int exit_code = patch_status ? |
| + patch_status + kBsdiffErrorOffset : 0; |
| + if (exit_code) { |
| + VLOG(1) << "Failed to apply patch " << patch.value() |
| + << ". err=" << exit_code; |
| + } |
| + |
| + return exit_code; |
| +} |
| + |
| int ApplyDiffPatch(const base::FilePath& src, |
| const base::FilePath& patch, |
| const base::FilePath& dest, |
| @@ -119,8 +171,14 @@ int ApplyDiffPatch(const base::FilePath& src, |
| if (installer_state != NULL) |
| installer_state->UpdateStage(installer::BINARY_PATCHING); |
| - return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), |
| - dest.value().c_str()); |
| + int binary_patch_status = ApplyBinaryPatch(src.value().c_str(), |
| + patch.value().c_str(), |
| + dest.value().c_str()); |
| + |
| + VLOG(1) << "Failed to apply patch " << patch.value() |
| + << " using bsdiff. err=" << binary_patch_status; |
| + |
| + return binary_patch_status; |
| } |
| Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { |