| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // The file contains the implementation of the mini_installer re-versioner. | 5 // The file contains the implementation of the mini_installer re-versioner. |
| 6 // The main function (GenerateNextVersion) does the following in a temp dir: | 6 // The main function (GenerateNextVersion) does the following in a temp dir: |
| 7 // - Extracts and unpacks setup.exe and the Chrome-bin folder from | 7 // - Extracts and unpacks setup.exe and the Chrome-bin folder from |
| 8 // mini_installer.exe. | 8 // mini_installer.exe. |
| 9 // - Inspects setup.exe to determine the current version. | 9 // - Inspects setup.exe to determine the current version. |
| 10 // - Runs through all .dll and .exe files: | 10 // - Runs through all .dll and .exe files: |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 std::string new_version(context->new_version.ToASCII()); | 418 std::string new_version(context->new_version.ToASCII()); |
| 419 bool modified = false; | 419 bool modified = false; |
| 420 if (!ReplaceAll(reinterpret_cast<uint8_t*>(&contents[0]), | 420 if (!ReplaceAll(reinterpret_cast<uint8_t*>(&contents[0]), |
| 421 reinterpret_cast<uint8_t*>(&contents[contents.size()]), | 421 reinterpret_cast<uint8_t*>(&contents[contents.size()]), |
| 422 reinterpret_cast<uint8_t*>(&old_version[0]), | 422 reinterpret_cast<uint8_t*>(&old_version[0]), |
| 423 reinterpret_cast<uint8_t*>(&old_version[old_version.size()]), | 423 reinterpret_cast<uint8_t*>(&old_version[old_version.size()]), |
| 424 reinterpret_cast<uint8_t*>(&new_version[0]), &modified)) { | 424 reinterpret_cast<uint8_t*>(&new_version[0]), &modified)) { |
| 425 return false; | 425 return false; |
| 426 } | 426 } |
| 427 DCHECK(modified); | 427 DCHECK(modified); |
| 428 return base::WriteFile(manifest, &contents[0], contents.size()) == | 428 int written = base::WriteFile(manifest, &contents[0], contents.size()); |
| 429 contents.size(); | 429 return written != -1 && static_cast<size_t>(written) == contents.size(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 bool IncrementNewVersion(upgrade_test::Direction direction, | 432 bool IncrementNewVersion(upgrade_test::Direction direction, |
| 433 VisitResourceContext* ctx) { | 433 VisitResourceContext* ctx) { |
| 434 DCHECK(ctx); | 434 DCHECK(ctx); |
| 435 | 435 |
| 436 // Figure out a past or future version with the same string length as this one | 436 // Figure out a past or future version with the same string length as this one |
| 437 // by decrementing or incrementing each component. | 437 // by decrementing or incrementing each component. |
| 438 LONGLONG incrementer = (direction == upgrade_test::PREVIOUS_VERSION ? -1 : 1); | 438 LONGLONG incrementer = (direction == upgrade_test::PREVIOUS_VERSION ? -1 : 1); |
| 439 | 439 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 return false; | 762 return false; |
| 763 } | 763 } |
| 764 ctx.current_version_str = ctx.current_version.ToString(); | 764 ctx.current_version_str = ctx.current_version.ToString(); |
| 765 ctx.new_version = ChromeVersion::FromString(version.GetString()); | 765 ctx.new_version = ChromeVersion::FromString(version.GetString()); |
| 766 ctx.new_version_str = ctx.new_version.ToString(); | 766 ctx.new_version_str = ctx.new_version.ToString(); |
| 767 | 767 |
| 768 return UpdateVersionIfMatch(target_file, &ctx); | 768 return UpdateVersionIfMatch(target_file, &ctx); |
| 769 } | 769 } |
| 770 | 770 |
| 771 } // namespace upgrade_test | 771 } // namespace upgrade_test |
| OLD | NEW |