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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } else { | 204 } else { |
205 PLOG(DFATAL) << "CreateFileMapping failed"; | 205 PLOG(DFATAL) << "CreateFileMapping failed"; |
206 } | 206 } |
207 } else { | 207 } else { |
208 LOG(DFATAL) << "Files larger than " << std::numeric_limits<DWORD>::max() | 208 LOG(DFATAL) << "Files larger than " << std::numeric_limits<DWORD>::max() |
209 << " are not supported."; | 209 << " are not supported."; |
210 } | 210 } |
211 } else { | 211 } else { |
212 PLOG(DFATAL) << "file.GetInfo failed"; | 212 PLOG(DFATAL) << "file.GetInfo failed"; |
213 } | 213 } |
214 file_ = file.Pass(); | 214 file_ = std::move(file); |
215 return result; | 215 return result; |
216 } | 216 } |
217 | 217 |
218 // Calls CreateProcess with good default parameters and waits for the process | 218 // Calls CreateProcess with good default parameters and waits for the process |
219 // to terminate returning the process exit code. | 219 // to terminate returning the process exit code. |
220 bool RunProcessAndWait(const wchar_t* exe_path, const std::wstring& cmdline, | 220 bool RunProcessAndWait(const wchar_t* exe_path, const std::wstring& cmdline, |
221 int* exit_code) { | 221 int* exit_code) { |
222 bool result = true; | 222 bool result = true; |
223 base::LaunchOptions options; | 223 base::LaunchOptions options; |
224 options.wait = true; | 224 options.wait = true; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 int retries = 3; | 384 int retries = 3; |
385 while (!file.IsValid() && retries-- > 0) { | 385 while (!file.IsValid() && retries-- > 0) { |
386 LOG(WARNING) << "Failed to open \"" << image_file.value() << "\"." | 386 LOG(WARNING) << "Failed to open \"" << image_file.value() << "\"." |
387 << " Retrying " << retries << " more times."; | 387 << " Retrying " << retries << " more times."; |
388 Sleep(1000); | 388 Sleep(1000); |
389 file.Initialize(image_file, flags); | 389 file.Initialize(image_file, flags); |
390 } | 390 } |
391 | 391 |
392 if (file.IsValid()) { | 392 if (file.IsValid()) { |
393 MappedFile image_mapping; | 393 MappedFile image_mapping; |
394 if (image_mapping.Initialize(file.Pass())) { | 394 if (image_mapping.Initialize(std::move(file))) { |
395 base::win::PEImageAsData image( | 395 base::win::PEImageAsData image( |
396 reinterpret_cast<HMODULE>(image_mapping.data())); | 396 reinterpret_cast<HMODULE>(image_mapping.data())); |
397 // PEImage class does not support other-architecture images. | 397 // PEImage class does not support other-architecture images. |
398 if (image.GetNTHeaders()->OptionalHeader.Magic == | 398 if (image.GetNTHeaders()->OptionalHeader.Magic == |
399 IMAGE_NT_OPTIONAL_HDR_MAGIC) { | 399 IMAGE_NT_OPTIONAL_HDR_MAGIC) { |
400 result = upgrade_test::EnumResources( | 400 result = upgrade_test::EnumResources( |
401 image, &VisitResource, reinterpret_cast<uintptr_t>(context)); | 401 image, &VisitResource, reinterpret_cast<uintptr_t>(context)); |
402 } else { | 402 } else { |
403 result = true; | 403 result = true; |
404 } | 404 } |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 return false; | 763 return false; |
764 } | 764 } |
765 ctx.current_version_str = ctx.current_version.ToString(); | 765 ctx.current_version_str = ctx.current_version.ToString(); |
766 ctx.new_version = ChromeVersion::FromString(version.GetString()); | 766 ctx.new_version = ChromeVersion::FromString(version.GetString()); |
767 ctx.new_version_str = ctx.new_version.ToString(); | 767 ctx.new_version_str = ctx.new_version.ToString(); |
768 | 768 |
769 return UpdateVersionIfMatch(target_file, &ctx); | 769 return UpdateVersionIfMatch(target_file, &ctx); |
770 } | 770 } |
771 | 771 |
772 } // namespace upgrade_test | 772 } // namespace upgrade_test |
OLD | NEW |