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

Side by Side Diff: chrome/installer/setup/setup_main.cc

Issue 1735153002: Add installer metrics for operations on the archive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
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
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;
261 265
262 // Short-circuit if uncompression produced the uncompressed archive rather 266 // Short-circuit if uncompression produced the uncompressed archive rather
263 // than a patch file. 267 // than a patch file.
264 if (base::PathExists(archive_helper->target())) { 268 if (base::PathExists(archive_helper->target())) {
bcwhite 2016/02/25 16:46:50 Could extract the condition into a bool and have o
grt (UTC plus 2) 2016/02/25 17:45:26 Done.
265 *archive_type = installer::FULL_ARCHIVE_TYPE; 269 *archive_type = installer::FULL_ARCHIVE_TYPE;
270 UMA_HISTOGRAM_BOOLEAN("Setup.Install.HasArchivePatch", false);
271 // Uncompression alone hopefully takes less than 3 minutes even on slow
272 // machines.
273 UMA_HISTOGRAM_MEDIUM_TIMES("Setup.Install.UncompressFullArchiveTime",
274 elapsed_time);
266 return true; 275 return true;
267 } 276 }
268 277
278 UMA_HISTOGRAM_BOOLEAN("Setup.Install.HasArchivePatch", true);
279 UMA_HISTOGRAM_MEDIUM_TIMES("Setup.Install.UncompressArchivePatchTime",
280 elapsed_time);
281
269 // Find the installed version's archive to serve as the source for patching. 282 // Find the installed version's archive to serve as the source for patching.
270 base::FilePath patch_source(installer::FindArchiveToPatch(original_state, 283 base::FilePath patch_source(installer::FindArchiveToPatch(original_state,
271 installer_state, 284 installer_state,
272 previous_version)); 285 previous_version));
273 if (patch_source.empty()) { 286 if (patch_source.empty()) {
274 LOG(ERROR) << "Failed to find archive to patch."; 287 LOG(ERROR) << "Failed to find archive to patch.";
275 *install_status = installer::DIFF_PATCH_SOURCE_MISSING; 288 *install_status = installer::DIFF_PATCH_SOURCE_MISSING;
276 installer_state.WriteInstallerResult(*install_status, 289 installer_state.WriteInstallerResult(*install_status,
277 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, 290 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE,
278 NULL); 291 NULL);
279 return false; 292 return false;
280 } 293 }
281 archive_helper->set_patch_source(patch_source); 294 archive_helper->set_patch_source(patch_source);
282 295
283 // Try courgette first. Failing that, try bspatch. 296 // Try courgette first. Failing that, try bspatch.
297 // Patch application sometimes takes a very long time, so use 100 buckets for
298 // up to an hour.
299 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Setup.Install.ApplyArchivePathTime");
bcwhite 2016/02/25 16:46:50 ApplyArchivePatchTime (Patch vs Path)
grt (UTC plus 2) 2016/02/25 17:45:26 Done.
284 installer_state.UpdateStage(installer::ENSEMBLE_PATCHING); 300 installer_state.UpdateStage(installer::ENSEMBLE_PATCHING);
285 if (!archive_helper->EnsemblePatch()) { 301 if (!archive_helper->EnsemblePatch()) {
286 installer_state.UpdateStage(installer::BINARY_PATCHING); 302 installer_state.UpdateStage(installer::BINARY_PATCHING);
287 if (!archive_helper->BinaryPatch()) { 303 if (!archive_helper->BinaryPatch()) {
288 *install_status = installer::APPLY_DIFF_PATCH_FAILED; 304 *install_status = installer::APPLY_DIFF_PATCH_FAILED;
289 installer_state.WriteInstallerResult( 305 installer_state.WriteInstallerResult(
290 *install_status, IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); 306 *install_status, IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL);
291 return false; 307 return false;
292 } 308 }
293 } 309 }
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 !base::PathExists(uncompressed_archive)) { 1429 !base::PathExists(uncompressed_archive)) {
1414 LOG(ERROR) << "Cannot install Chrome without an uncompressed archive."; 1430 LOG(ERROR) << "Cannot install Chrome without an uncompressed archive.";
1415 installer_state.WriteInstallerResult( 1431 installer_state.WriteInstallerResult(
1416 INVALID_ARCHIVE, IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); 1432 INVALID_ARCHIVE, IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL);
1417 return INVALID_ARCHIVE; 1433 return INVALID_ARCHIVE;
1418 } 1434 }
1419 *archive_type = FULL_ARCHIVE_TYPE; 1435 *archive_type = FULL_ARCHIVE_TYPE;
1420 } 1436 }
1421 1437
1422 // Unpack the uncompressed archive. 1438 // Unpack the uncompressed archive.
1439 base::TimeTicks start_time = base::TimeTicks::Now();
1423 if (LzmaUtil::UnPackArchive(uncompressed_archive.value(), 1440 if (LzmaUtil::UnPackArchive(uncompressed_archive.value(),
1424 unpack_path.value(), 1441 unpack_path.value(),
1425 NULL)) { 1442 NULL)) {
1426 installer_state.WriteInstallerResult( 1443 installer_state.WriteInstallerResult(
1427 UNPACKING_FAILED, 1444 UNPACKING_FAILED,
1428 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, 1445 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE,
1429 NULL); 1446 NULL);
1430 return UNPACKING_FAILED; 1447 return UNPACKING_FAILED;
1431 } 1448 }
1449 UMA_HISTOGRAM_MEDIUM_TIMES("Setup.Install.UnpackFullArchiveTime",
1450 base::TimeTicks::Now() - start_time);
1432 1451
1433 VLOG(1) << "unpacked to " << unpack_path.value(); 1452 VLOG(1) << "unpacked to " << unpack_path.value();
1434 base::FilePath src_path( 1453 base::FilePath src_path(
1435 unpack_path.Append(kInstallSourceChromeDir)); 1454 unpack_path.Append(kInstallSourceChromeDir));
1436 scoped_ptr<Version> 1455 scoped_ptr<Version>
1437 installer_version(GetMaxVersionFromArchiveDir(src_path)); 1456 installer_version(GetMaxVersionFromArchiveDir(src_path));
1438 if (!installer_version.get()) { 1457 if (!installer_version.get()) {
1439 LOG(ERROR) << "Did not find any valid version in installer."; 1458 LOG(ERROR) << "Did not find any valid version in installer.";
1440 install_status = INVALID_ARCHIVE; 1459 install_status = INVALID_ARCHIVE;
1441 installer_state.WriteInstallerResult(install_status, 1460 installer_state.WriteInstallerResult(install_status,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 // to pass through, since this is only returned on uninstall which is 1804 // to pass through, since this is only returned on uninstall which is
1786 // never invoked directly by Google Update. 1805 // never invoked directly by Google Update.
1787 return_code = InstallUtil::GetInstallReturnCode(install_status); 1806 return_code = InstallUtil::GetInstallReturnCode(install_status);
1788 } 1807 }
1789 1808
1790 installer::EndPersistentHistogramStorage(installer_state.target_path()); 1809 installer::EndPersistentHistogramStorage(installer_state.target_path());
1791 VLOG(1) << "Installation complete, returning: " << return_code; 1810 VLOG(1) << "Installation complete, returning: " << return_code;
1792 1811
1793 return return_code; 1812 return return_code;
1794 } 1813 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698