| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 }; // class ScopedTempDirectory | 101 }; // class ScopedTempDirectory |
| 102 | 102 |
| 103 // A helper class for manipulating a Chrome product version. | 103 // A helper class for manipulating a Chrome product version. |
| 104 class ChromeVersion { | 104 class ChromeVersion { |
| 105 public: | 105 public: |
| 106 static ChromeVersion FromHighLow(DWORD high, DWORD low) { | 106 static ChromeVersion FromHighLow(DWORD high, DWORD low) { |
| 107 return ChromeVersion(static_cast<ULONGLONG>(high) << 32 | | 107 return ChromeVersion(static_cast<ULONGLONG>(high) << 32 | |
| 108 static_cast<ULONGLONG>(low)); | 108 static_cast<ULONGLONG>(low)); |
| 109 } | 109 } |
| 110 static ChromeVersion FromString(const std::string& version_string) { | 110 static ChromeVersion FromString(const std::string& version_string) { |
| 111 base::Version version(version_string); | 111 Version version(version_string); |
| 112 DCHECK(version.IsValid()); | 112 DCHECK(version.IsValid()); |
| 113 const std::vector<uint16>& c(version.components()); | 113 const std::vector<uint16>& c(version.components()); |
| 114 return ChromeVersion(static_cast<ULONGLONG>(c[0]) << 48 | | 114 return ChromeVersion(static_cast<ULONGLONG>(c[0]) << 48 | |
| 115 static_cast<ULONGLONG>(c[1]) << 32 | | 115 static_cast<ULONGLONG>(c[1]) << 32 | |
| 116 static_cast<ULONGLONG>(c[2]) << 16 | | 116 static_cast<ULONGLONG>(c[2]) << 16 | |
| 117 static_cast<ULONGLONG>(c[3])); | 117 static_cast<ULONGLONG>(c[3])); |
| 118 } | 118 } |
| 119 | 119 |
| 120 ChromeVersion() { } | 120 ChromeVersion() { } |
| 121 explicit ChromeVersion(ULONGLONG value) : version_(value) { } | 121 explicit ChromeVersion(ULONGLONG value) : version_(value) { } |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 return false; | 662 return false; |
| 663 } | 663 } |
| 664 ctx.current_version_str = ctx.current_version.ToString(); | 664 ctx.current_version_str = ctx.current_version.ToString(); |
| 665 | 665 |
| 666 if (!IncrementNewVersion(direction, &ctx)) { | 666 if (!IncrementNewVersion(direction, &ctx)) { |
| 667 LOG(DFATAL) << "Failed to increment version from \"" | 667 LOG(DFATAL) << "Failed to increment version from \"" |
| 668 << original_file.value() << "\""; | 668 << original_file.value() << "\""; |
| 669 return false; | 669 return false; |
| 670 } | 670 } |
| 671 | 671 |
| 672 base::Version new_version(WideToASCII(ctx.new_version_str)); | 672 Version new_version(WideToASCII(ctx.new_version_str)); |
| 673 GenerateSpecificPEFileVersion(original_file, target_file, new_version); | 673 GenerateSpecificPEFileVersion(original_file, target_file, new_version); |
| 674 | 674 |
| 675 return true; | 675 return true; |
| 676 } | 676 } |
| 677 | 677 |
| 678 bool GenerateSpecificPEFileVersion(const base::FilePath& original_file, | 678 bool GenerateSpecificPEFileVersion(const base::FilePath& original_file, |
| 679 const base::FilePath& target_file, | 679 const base::FilePath& target_file, |
| 680 const base::Version& version) { | 680 const Version& version) { |
| 681 // First copy original_file to target_file. | 681 // First copy original_file to target_file. |
| 682 if (!base::CopyFile(original_file, target_file)) { | 682 if (!base::CopyFile(original_file, target_file)) { |
| 683 LOG(DFATAL) << "Failed copying \"" << original_file.value() | 683 LOG(DFATAL) << "Failed copying \"" << original_file.value() |
| 684 << "\" to \"" << target_file.value() << "\""; | 684 << "\" to \"" << target_file.value() << "\""; |
| 685 return false; | 685 return false; |
| 686 } | 686 } |
| 687 | 687 |
| 688 VisitResourceContext ctx; | 688 VisitResourceContext ctx; |
| 689 if (!GetFileVersion(target_file, &ctx.current_version)) { | 689 if (!GetFileVersion(target_file, &ctx.current_version)) { |
| 690 LOG(DFATAL) << "Failed reading version from \"" << target_file.value() | 690 LOG(DFATAL) << "Failed reading version from \"" << target_file.value() |
| 691 << "\""; | 691 << "\""; |
| 692 return false; | 692 return false; |
| 693 } | 693 } |
| 694 ctx.current_version_str = ctx.current_version.ToString(); | 694 ctx.current_version_str = ctx.current_version.ToString(); |
| 695 ctx.new_version = ChromeVersion::FromString(version.GetString()); | 695 ctx.new_version = ChromeVersion::FromString(version.GetString()); |
| 696 ctx.new_version_str = ctx.new_version.ToString(); | 696 ctx.new_version_str = ctx.new_version.ToString(); |
| 697 | 697 |
| 698 return UpdateVersionIfMatch(target_file, &ctx); | 698 return UpdateVersionIfMatch(target_file, &ctx); |
| 699 } | 699 } |
| 700 | 700 |
| 701 } // namespace upgrade_test | 701 } // namespace upgrade_test |
| OLD | NEW |