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

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

Issue 7866043: Prevent redirector from returning the current module in cases where it fails to look up the first... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | « no previous file | chrome_frame/dll_redirector.h » ('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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (!file_util::CreateNewTempDirectory(&kTempDirPrefix[0], &directory_)) { 83 if (!file_util::CreateNewTempDirectory(&kTempDirPrefix[0], &directory_)) {
84 LOG(DFATAL) << "Failed creating temporary directory."; 84 LOG(DFATAL) << "Failed creating temporary directory.";
85 return false; 85 return false;
86 } 86 }
87 return true; 87 return true;
88 } 88 }
89 const FilePath& directory() const { 89 const FilePath& directory() const {
90 DCHECK(!directory_.empty()); 90 DCHECK(!directory_.empty());
91 return directory_; 91 return directory_;
92 } 92 }
93
93 private: 94 private:
94 FilePath directory_; 95 FilePath directory_;
95 DISALLOW_COPY_AND_ASSIGN(ScopedTempDirectory); 96 DISALLOW_COPY_AND_ASSIGN(ScopedTempDirectory);
96 }; // class ScopedTempDirectory 97 }; // class ScopedTempDirectory
97 98
98 // A helper class for manipulating a Chrome product version. 99 // A helper class for manipulating a Chrome product version.
99 class ChromeVersion { 100 class ChromeVersion {
100 public: 101 public:
101 static ChromeVersion FromHighLow(DWORD high, DWORD low) { 102 static ChromeVersion FromHighLow(DWORD high, DWORD low) {
102 return ChromeVersion(static_cast<ULONGLONG>(high) << 32 | 103 return ChromeVersion(static_cast<ULONGLONG>(high) << 32 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 330
330 // Updates the version strings and numbers in all of |image_file|'s resources. 331 // Updates the version strings and numbers in all of |image_file|'s resources.
331 bool UpdateVersionIfMatch(const FilePath& image_file, 332 bool UpdateVersionIfMatch(const FilePath& image_file,
332 VisitResourceContext* context) { 333 VisitResourceContext* context) {
333 bool result = false; 334 bool result = false;
334 base::win::ScopedHandle image_handle(base::CreatePlatformFile( 335 base::win::ScopedHandle image_handle(base::CreatePlatformFile(
335 image_file, 336 image_file,
336 (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | 337 (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ |
337 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_READ | 338 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_READ |
338 base::PLATFORM_FILE_EXCLUSIVE_WRITE), NULL, NULL)); 339 base::PLATFORM_FILE_EXCLUSIVE_WRITE), NULL, NULL));
339 if (image_handle.Get() != INVALID_HANDLE_VALUE) { 340 // It turns out that the underlying CreateFile can fail due to unhelpful
341 // security software locking the newly created DLL. So add a few brief
342 // retries to help tests that use this pass on machines thusly encumbered.
343 int retries = 3;
344 while (!image_handle.IsValid() && retries-- > 0) {
345 LOG(WARNING) << "Failed to open \"" << image_file.value() << "\"."
346 << " Retrying " << retries << " more times.";
347 Sleep(1000);
348 image_handle.Set(base::CreatePlatformFile(
349 image_file,
350 (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ |
351 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_READ |
352 base::PLATFORM_FILE_EXCLUSIVE_WRITE), NULL, NULL));
353 }
354
355 if (image_handle.IsValid()) {
340 MappedFile image_mapping; 356 MappedFile image_mapping;
341 if (image_mapping.Initialize(image_handle)) { 357 if (image_mapping.Initialize(image_handle)) {
342 base::win::PEImageAsData image( 358 base::win::PEImageAsData image(
343 reinterpret_cast<HMODULE>(image_mapping.data())); 359 reinterpret_cast<HMODULE>(image_mapping.data()));
344 // PEImage class does not support other-architecture images. 360 // PEImage class does not support other-architecture images.
345 if (image.GetNTHeaders()->OptionalHeader.Magic == 361 if (image.GetNTHeaders()->OptionalHeader.Magic ==
346 IMAGE_NT_OPTIONAL_HDR_MAGIC) { 362 IMAGE_NT_OPTIONAL_HDR_MAGIC) {
347 result = upgrade_test::EnumResources( 363 result = upgrade_test::EnumResources(
348 image, &VisitResource, reinterpret_cast<uintptr_t>(context)); 364 image, &VisitResource, reinterpret_cast<uintptr_t>(context));
349 } else { 365 } else {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 !UpdateVersionIfMatch(target_file, &ctx)) { 652 !UpdateVersionIfMatch(target_file, &ctx)) {
637 LOG(DFATAL) << "Failed to update version in \"" << target_file.value() 653 LOG(DFATAL) << "Failed to update version in \"" << target_file.value()
638 << "\""; 654 << "\"";
639 return false; 655 return false;
640 } 656 }
641 657
642 return true; 658 return true;
643 } 659 }
644 660
645 } // namespace upgrade_test 661 } // namespace upgrade_test
OLDNEW
« no previous file with comments | « no previous file | chrome_frame/dll_redirector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698