Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/installer/test/alternate_version_generator.cc

Issue 176843022: Move UTF16ToASCII, remove WideToASCII. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/setup/uninstall.cc ('k') | chrome/installer/util/google_update_settings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 #include "base/command_line.h" 35 #include "base/command_line.h"
36 #include "base/file_util.h" 36 #include "base/file_util.h"
37 #include "base/files/file.h" 37 #include "base/files/file.h"
38 #include "base/files/file_enumerator.h" 38 #include "base/files/file_enumerator.h"
39 #include "base/files/file_path.h" 39 #include "base/files/file_path.h"
40 #include "base/logging.h" 40 #include "base/logging.h"
41 #include "base/path_service.h" 41 #include "base/path_service.h"
42 #include "base/process/launch.h" 42 #include "base/process/launch.h"
43 #include "base/process/process_handle.h" 43 #include "base/process/process_handle.h"
44 #include "base/strings/string_util.h" 44 #include "base/strings/string_util.h"
45 #include "base/strings/utf_string_conversions.h"
45 #include "base/version.h" 46 #include "base/version.h"
46 #include "base/win/pe_image.h" 47 #include "base/win/pe_image.h"
47 #include "base/win/scoped_handle.h" 48 #include "base/win/scoped_handle.h"
48 #include "chrome/installer/test/pe_image_resources.h" 49 #include "chrome/installer/test/pe_image_resources.h"
49 #include "chrome/installer/test/resource_loader.h" 50 #include "chrome/installer/test/resource_loader.h"
50 #include "chrome/installer/test/resource_updater.h" 51 #include "chrome/installer/test/resource_updater.h"
51 #include "chrome/installer/util/lzma_util.h" 52 #include "chrome/installer/util/lzma_util.h"
52 53
53 namespace { 54 namespace {
54 55
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return false; 661 return false;
661 } 662 }
662 ctx.current_version_str = ctx.current_version.ToString(); 663 ctx.current_version_str = ctx.current_version.ToString();
663 664
664 if (!IncrementNewVersion(direction, &ctx)) { 665 if (!IncrementNewVersion(direction, &ctx)) {
665 LOG(DFATAL) << "Failed to increment version from \"" 666 LOG(DFATAL) << "Failed to increment version from \""
666 << original_file.value() << "\""; 667 << original_file.value() << "\"";
667 return false; 668 return false;
668 } 669 }
669 670
670 Version new_version(WideToASCII(ctx.new_version_str)); 671 Version new_version(base::UTF16ToASCII(ctx.new_version_str));
671 GenerateSpecificPEFileVersion(original_file, target_file, new_version); 672 GenerateSpecificPEFileVersion(original_file, target_file, new_version);
672 673
673 return true; 674 return true;
674 } 675 }
675 676
676 bool GenerateSpecificPEFileVersion(const base::FilePath& original_file, 677 bool GenerateSpecificPEFileVersion(const base::FilePath& original_file,
677 const base::FilePath& target_file, 678 const base::FilePath& target_file,
678 const Version& version) { 679 const Version& version) {
679 // First copy original_file to target_file. 680 // First copy original_file to target_file.
680 if (!base::CopyFile(original_file, target_file)) { 681 if (!base::CopyFile(original_file, target_file)) {
681 LOG(DFATAL) << "Failed copying \"" << original_file.value() 682 LOG(DFATAL) << "Failed copying \"" << original_file.value()
682 << "\" to \"" << target_file.value() << "\""; 683 << "\" to \"" << target_file.value() << "\"";
683 return false; 684 return false;
684 } 685 }
685 686
686 VisitResourceContext ctx; 687 VisitResourceContext ctx;
687 if (!GetFileVersion(target_file, &ctx.current_version)) { 688 if (!GetFileVersion(target_file, &ctx.current_version)) {
688 LOG(DFATAL) << "Failed reading version from \"" << target_file.value() 689 LOG(DFATAL) << "Failed reading version from \"" << target_file.value()
689 << "\""; 690 << "\"";
690 return false; 691 return false;
691 } 692 }
692 ctx.current_version_str = ctx.current_version.ToString(); 693 ctx.current_version_str = ctx.current_version.ToString();
693 ctx.new_version = ChromeVersion::FromString(version.GetString()); 694 ctx.new_version = ChromeVersion::FromString(version.GetString());
694 ctx.new_version_str = ctx.new_version.ToString(); 695 ctx.new_version_str = ctx.new_version.ToString();
695 696
696 return UpdateVersionIfMatch(target_file, &ctx); 697 return UpdateVersionIfMatch(target_file, &ctx);
697 } 698 }
698 699
699 } // namespace upgrade_test 700 } // namespace upgrade_test
OLDNEW
« no previous file with comments | « chrome/installer/setup/uninstall.cc ('k') | chrome/installer/util/google_update_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698