Commit 813f1ec9 authored by Swapnil's avatar Swapnil Committed by Commit Bot

Fix crash caused by installation times

When the installation times are reported, it may be possible that we
do not come across the previous stage and thus it would access the
optional field to report the installation time which would then lead
to a crash. It is safer to report the time when we are sure that
the initial stage and the next stage are reported. For eg, it is
possible to report the kComplete installation stage even when
the extension fails to install.

Bug: 1119352
Change-Id: I20a5ee31451106832f8f0791f95b78efb8b3d66b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362803Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Reviewed-by: default avatarSaurabh Nijhara <snijhara@google.com>
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Cr-Commit-Position: refs/heads/master@{#800063}
parent 1452b0cd
...@@ -119,7 +119,8 @@ bool ForceInstalledMetrics::IsMisconfiguration( ...@@ -119,7 +119,8 @@ bool ForceInstalledMetrics::IsMisconfiguration(
if (detail == CrxInstallErrorDetail::KIOSK_MODE_ONLY) if (detail == CrxInstallErrorDetail::KIOSK_MODE_ONLY)
return true; return true;
if (detail == CrxInstallErrorDetail::DISALLOWED_BY_POLICY && if (installation_data.extension_type &&
detail == CrxInstallErrorDetail::DISALLOWED_BY_POLICY &&
!management->IsAllowedManifestType( !management->IsAllowedManifestType(
installation_data.extension_type.value(), id)) { installation_data.extension_type.value(), id)) {
return true; return true;
...@@ -172,8 +173,8 @@ void ForceInstalledMetrics::ReportMetrics() { ...@@ -172,8 +173,8 @@ void ForceInstalledMetrics::ReportMetrics() {
} else { } else {
InstallStageTracker::InstallationData installation = InstallStageTracker::InstallationData installation =
install_stage_tracker->Get(extension.first); install_stage_tracker->Get(extension.first);
if (installation.download_manifest_finish_time) { if (installation.download_manifest_finish_time &&
DCHECK(installation.download_manifest_started_time); installation.download_manifest_started_time) {
base::UmaHistogramLongTimes( base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.DownloadingStartTo." "Extensions.ForceInstalledTime.DownloadingStartTo."
"ManifestDownloadComplete", "ManifestDownloadComplete",
...@@ -198,31 +199,31 @@ void ForceInstalledMetrics::ReportMetrics() { ...@@ -198,31 +199,31 @@ void ForceInstalledMetrics::ReportMetrics() {
installation.copying_started_time.value() - installation.copying_started_time.value() -
installation.verification_started_time.value()); installation.verification_started_time.value());
} }
if (installation.unpacking_started_time) { if (installation.unpacking_started_time &&
DCHECK(installation.copying_started_time); installation.copying_started_time) {
base::UmaHistogramLongTimes( base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.CopyingStartTo.UnpackingStart", "Extensions.ForceInstalledTime.CopyingStartTo.UnpackingStart",
installation.unpacking_started_time.value() - installation.unpacking_started_time.value() -
installation.copying_started_time.value()); installation.copying_started_time.value());
} }
if (installation.checking_expectations_started_time) { if (installation.checking_expectations_started_time &&
DCHECK(installation.unpacking_started_time); installation.unpacking_started_time) {
base::UmaHistogramLongTimes( base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.UnpackingStartTo." "Extensions.ForceInstalledTime.UnpackingStartTo."
"CheckingExpectationsStart", "CheckingExpectationsStart",
installation.checking_expectations_started_time.value() - installation.checking_expectations_started_time.value() -
installation.unpacking_started_time.value()); installation.unpacking_started_time.value());
} }
if (installation.finalizing_started_time) { if (installation.finalizing_started_time &&
DCHECK(installation.checking_expectations_started_time); installation.checking_expectations_started_time) {
base::UmaHistogramLongTimes( base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.CheckingExpectationsStartTo." "Extensions.ForceInstalledTime.CheckingExpectationsStartTo."
"FinalizingStart", "FinalizingStart",
installation.finalizing_started_time.value() - installation.finalizing_started_time.value() -
installation.checking_expectations_started_time.value()); installation.checking_expectations_started_time.value());
} }
if (installation.installation_complete_time) { if (installation.installation_complete_time &&
DCHECK(installation.finalizing_started_time); installation.finalizing_started_time) {
base::UmaHistogramLongTimes( base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.FinalizingStartTo." "Extensions.ForceInstalledTime.FinalizingStartTo."
"CRXInstallComplete", "CRXInstallComplete",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment