OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/installer/setup/setup_main.h" | 5 #include "chrome/installer/setup/setup_main.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <msi.h> | 8 #include <msi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 #include <stddef.h> | 11 #include <stddef.h> |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/file_version_info.h" | 18 #include "base/file_version_info.h" |
19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
21 #include "base/files/scoped_temp_dir.h" | 21 #include "base/files/scoped_temp_dir.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "base/metrics/histogram_macros.h" |
24 #include "base/path_service.h" | 25 #include "base/path_service.h" |
25 #include "base/process/launch.h" | 26 #include "base/process/launch.h" |
26 #include "base/process/memory.h" | 27 #include "base/process/memory.h" |
27 #include "base/strings/string16.h" | 28 #include "base/strings/string16.h" |
28 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
29 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
30 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
31 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 33 #include "base/time/time.h" |
32 #include "base/values.h" | 34 #include "base/values.h" |
33 #include "base/version.h" | 35 #include "base/version.h" |
34 #include "base/win/process_startup_helper.h" | 36 #include "base/win/process_startup_helper.h" |
35 #include "base/win/registry.h" | 37 #include "base/win/registry.h" |
36 #include "base/win/scoped_com_initializer.h" | 38 #include "base/win/scoped_com_initializer.h" |
37 #include "base/win/scoped_comptr.h" | 39 #include "base/win/scoped_comptr.h" |
38 #include "base/win/scoped_handle.h" | 40 #include "base/win/scoped_handle.h" |
39 #include "base/win/win_util.h" | 41 #include "base/win/win_util.h" |
40 #include "base/win/windows_version.h" | 42 #include "base/win/windows_version.h" |
41 #include "chrome/common/chrome_constants.h" | 43 #include "chrome/common/chrome_constants.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // Returns false on failure, in which case |install_status| contains the error | 246 // Returns false on failure, in which case |install_status| contains the error |
245 // code and the result is written to the registry (via WriteInstallerResult). | 247 // code and the result is written to the registry (via WriteInstallerResult). |
246 bool UncompressAndPatchChromeArchive( | 248 bool UncompressAndPatchChromeArchive( |
247 const installer::InstallationState& original_state, | 249 const installer::InstallationState& original_state, |
248 const installer::InstallerState& installer_state, | 250 const installer::InstallerState& installer_state, |
249 installer::ArchivePatchHelper* archive_helper, | 251 installer::ArchivePatchHelper* archive_helper, |
250 installer::ArchiveType* archive_type, | 252 installer::ArchiveType* archive_type, |
251 installer::InstallStatus* install_status, | 253 installer::InstallStatus* install_status, |
252 const base::Version& previous_version) { | 254 const base::Version& previous_version) { |
253 installer_state.UpdateStage(installer::UNCOMPRESSING); | 255 installer_state.UpdateStage(installer::UNCOMPRESSING); |
| 256 base::TimeTicks start_time = base::TimeTicks::Now(); |
254 if (!archive_helper->Uncompress(NULL)) { | 257 if (!archive_helper->Uncompress(NULL)) { |
255 *install_status = installer::UNCOMPRESSION_FAILED; | 258 *install_status = installer::UNCOMPRESSION_FAILED; |
256 installer_state.WriteInstallerResult(*install_status, | 259 installer_state.WriteInstallerResult(*install_status, |
257 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, | 260 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, |
258 NULL); | 261 NULL); |
259 return false; | 262 return false; |
260 } | 263 } |
| 264 base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time; |
| 265 |
| 266 bool has_full_archive = base::PathExists(archive_helper->target()); |
| 267 UMA_HISTOGRAM_BOOLEAN("Setup.Install.HasArchivePatch", !has_full_archive); |
261 | 268 |
262 // Short-circuit if uncompression produced the uncompressed archive rather | 269 // Short-circuit if uncompression produced the uncompressed archive rather |
263 // than a patch file. | 270 // than a patch file. |
264 if (base::PathExists(archive_helper->target())) { | 271 if (has_full_archive) { |
265 *archive_type = installer::FULL_ARCHIVE_TYPE; | 272 *archive_type = installer::FULL_ARCHIVE_TYPE; |
| 273 // Uncompression alone hopefully takes less than 3 minutes even on slow |
| 274 // machines. |
| 275 UMA_HISTOGRAM_MEDIUM_TIMES("Setup.Install.UncompressFullArchiveTime", |
| 276 elapsed_time); |
266 return true; | 277 return true; |
267 } | 278 } |
268 | 279 |
| 280 UMA_HISTOGRAM_MEDIUM_TIMES("Setup.Install.UncompressArchivePatchTime", |
| 281 elapsed_time); |
| 282 |
269 // Find the installed version's archive to serve as the source for patching. | 283 // Find the installed version's archive to serve as the source for patching. |
270 base::FilePath patch_source(installer::FindArchiveToPatch(original_state, | 284 base::FilePath patch_source(installer::FindArchiveToPatch(original_state, |
271 installer_state, | 285 installer_state, |
272 previous_version)); | 286 previous_version)); |
273 if (patch_source.empty()) { | 287 if (patch_source.empty()) { |
274 LOG(ERROR) << "Failed to find archive to patch."; | 288 LOG(ERROR) << "Failed to find archive to patch."; |
275 *install_status = installer::DIFF_PATCH_SOURCE_MISSING; | 289 *install_status = installer::DIFF_PATCH_SOURCE_MISSING; |
276 installer_state.WriteInstallerResult(*install_status, | 290 installer_state.WriteInstallerResult(*install_status, |
277 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, | 291 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, |
278 NULL); | 292 NULL); |
279 return false; | 293 return false; |
280 } | 294 } |
281 archive_helper->set_patch_source(patch_source); | 295 archive_helper->set_patch_source(patch_source); |
282 | 296 |
283 // Try courgette first. Failing that, try bspatch. | 297 // Try courgette first. Failing that, try bspatch. |
| 298 // Patch application sometimes takes a very long time, so use 100 buckets for |
| 299 // up to an hour. |
| 300 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Setup.Install.ApplyArchivePatchTime"); |
284 installer_state.UpdateStage(installer::ENSEMBLE_PATCHING); | 301 installer_state.UpdateStage(installer::ENSEMBLE_PATCHING); |
285 if (!archive_helper->EnsemblePatch()) { | 302 if (!archive_helper->EnsemblePatch()) { |
286 installer_state.UpdateStage(installer::BINARY_PATCHING); | 303 installer_state.UpdateStage(installer::BINARY_PATCHING); |
287 if (!archive_helper->BinaryPatch()) { | 304 if (!archive_helper->BinaryPatch()) { |
288 *install_status = installer::APPLY_DIFF_PATCH_FAILED; | 305 *install_status = installer::APPLY_DIFF_PATCH_FAILED; |
289 installer_state.WriteInstallerResult( | 306 installer_state.WriteInstallerResult( |
290 *install_status, IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); | 307 *install_status, IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); |
291 return false; | 308 return false; |
292 } | 309 } |
293 } | 310 } |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 !base::PathExists(uncompressed_archive)) { | 1430 !base::PathExists(uncompressed_archive)) { |
1414 LOG(ERROR) << "Cannot install Chrome without an uncompressed archive."; | 1431 LOG(ERROR) << "Cannot install Chrome without an uncompressed archive."; |
1415 installer_state.WriteInstallerResult( | 1432 installer_state.WriteInstallerResult( |
1416 INVALID_ARCHIVE, IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 1433 INVALID_ARCHIVE, IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
1417 return INVALID_ARCHIVE; | 1434 return INVALID_ARCHIVE; |
1418 } | 1435 } |
1419 *archive_type = FULL_ARCHIVE_TYPE; | 1436 *archive_type = FULL_ARCHIVE_TYPE; |
1420 } | 1437 } |
1421 | 1438 |
1422 // Unpack the uncompressed archive. | 1439 // Unpack the uncompressed archive. |
| 1440 base::TimeTicks start_time = base::TimeTicks::Now(); |
1423 if (LzmaUtil::UnPackArchive(uncompressed_archive.value(), | 1441 if (LzmaUtil::UnPackArchive(uncompressed_archive.value(), |
1424 unpack_path.value(), | 1442 unpack_path.value(), |
1425 NULL)) { | 1443 NULL)) { |
1426 installer_state.WriteInstallerResult( | 1444 installer_state.WriteInstallerResult( |
1427 UNPACKING_FAILED, | 1445 UNPACKING_FAILED, |
1428 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, | 1446 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, |
1429 NULL); | 1447 NULL); |
1430 return UNPACKING_FAILED; | 1448 return UNPACKING_FAILED; |
1431 } | 1449 } |
| 1450 UMA_HISTOGRAM_MEDIUM_TIMES("Setup.Install.UnpackFullArchiveTime", |
| 1451 base::TimeTicks::Now() - start_time); |
1432 | 1452 |
1433 VLOG(1) << "unpacked to " << unpack_path.value(); | 1453 VLOG(1) << "unpacked to " << unpack_path.value(); |
1434 base::FilePath src_path( | 1454 base::FilePath src_path( |
1435 unpack_path.Append(kInstallSourceChromeDir)); | 1455 unpack_path.Append(kInstallSourceChromeDir)); |
1436 scoped_ptr<Version> | 1456 scoped_ptr<Version> |
1437 installer_version(GetMaxVersionFromArchiveDir(src_path)); | 1457 installer_version(GetMaxVersionFromArchiveDir(src_path)); |
1438 if (!installer_version.get()) { | 1458 if (!installer_version.get()) { |
1439 LOG(ERROR) << "Did not find any valid version in installer."; | 1459 LOG(ERROR) << "Did not find any valid version in installer."; |
1440 install_status = INVALID_ARCHIVE; | 1460 install_status = INVALID_ARCHIVE; |
1441 installer_state.WriteInstallerResult(install_status, | 1461 installer_state.WriteInstallerResult(install_status, |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 // to pass through, since this is only returned on uninstall which is | 1805 // to pass through, since this is only returned on uninstall which is |
1786 // never invoked directly by Google Update. | 1806 // never invoked directly by Google Update. |
1787 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1807 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1788 } | 1808 } |
1789 | 1809 |
1790 installer::EndPersistentHistogramStorage(installer_state.target_path()); | 1810 installer::EndPersistentHistogramStorage(installer_state.target_path()); |
1791 VLOG(1) << "Installation complete, returning: " << return_code; | 1811 VLOG(1) << "Installation complete, returning: " << return_code; |
1792 | 1812 |
1793 return return_code; | 1813 return return_code; |
1794 } | 1814 } |
OLD | NEW |