Commit 14cf28d6 authored by Swapnil's avatar Swapnil Committed by Commit Bot

[Refactoring] Report installation times in a new method

ForceInstalledMetrics::ReportMetrics is a large method and it would
be good to break it down into smaller sub-methods. This CL adds a new
method to report time taken during different installation stages for
force installed extensions.

Bug: 1127836
Change-Id: I36e3d9cc2b9b510dd3516c4f7642ef47809d2ad5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409937
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806973}
parent 38864a79
...@@ -65,6 +65,70 @@ ForceInstalledMetrics::UserType ConvertUserType( ...@@ -65,6 +65,70 @@ ForceInstalledMetrics::UserType ConvertUserType(
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// Reports time taken for force installed extension during different
// installation stages.
void ReportInstallationStageTimes(
const ExtensionId& extension_id,
const InstallStageTracker::InstallationData& installation) {
if (installation.download_manifest_finish_time &&
installation.download_manifest_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.DownloadingStartTo."
"ManifestDownloadComplete",
installation.download_manifest_finish_time.value() -
installation.download_manifest_started_time.value());
}
// Report the download time for CRX only when
// installation.download_CRX_started_time is set because in other case CRX
// is fetched from cache and the download was not started.
if (installation.download_CRX_finish_time &&
installation.download_CRX_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.ManifestDownloadCompleteTo."
"CRXDownloadComplete",
installation.download_CRX_finish_time.value() -
installation.download_CRX_started_time.value());
}
if (installation.copying_started_time) {
DCHECK(installation.verification_started_time);
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.VerificationStartTo.CopyingStart",
installation.copying_started_time.value() -
installation.verification_started_time.value());
}
if (installation.unpacking_started_time &&
installation.copying_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.CopyingStartTo.UnpackingStart",
installation.unpacking_started_time.value() -
installation.copying_started_time.value());
}
if (installation.checking_expectations_started_time &&
installation.unpacking_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.UnpackingStartTo."
"CheckingExpectationsStart",
installation.checking_expectations_started_time.value() -
installation.unpacking_started_time.value());
}
if (installation.finalizing_started_time &&
installation.checking_expectations_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.CheckingExpectationsStartTo."
"FinalizingStart",
installation.finalizing_started_time.value() -
installation.checking_expectations_started_time.value());
}
if (installation.installation_complete_time &&
installation.finalizing_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.FinalizingStartTo."
"CRXInstallComplete",
installation.installation_complete_time.value() -
installation.finalizing_started_time.value());
}
}
} // namespace } // namespace
ForceInstalledMetrics::ForceInstalledMetrics( ForceInstalledMetrics::ForceInstalledMetrics(
...@@ -127,63 +191,7 @@ void ForceInstalledMetrics::ReportMetrics() { ...@@ -127,63 +191,7 @@ 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 && ReportInstallationStageTimes(extension.first, installation);
installation.download_manifest_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.DownloadingStartTo."
"ManifestDownloadComplete",
installation.download_manifest_finish_time.value() -
installation.download_manifest_started_time.value());
}
// Report the download time for CRX only when
// installation.download_CRX_started_time is set because in other case CRX
// is fetched from cache and the download was not started.
if (installation.download_CRX_finish_time &&
installation.download_CRX_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.ManifestDownloadCompleteTo."
"CRXDownloadComplete",
installation.download_CRX_finish_time.value() -
installation.download_CRX_started_time.value());
}
if (installation.copying_started_time) {
DCHECK(installation.verification_started_time);
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.VerificationStartTo.CopyingStart",
installation.copying_started_time.value() -
installation.verification_started_time.value());
}
if (installation.unpacking_started_time &&
installation.copying_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.CopyingStartTo.UnpackingStart",
installation.unpacking_started_time.value() -
installation.copying_started_time.value());
}
if (installation.checking_expectations_started_time &&
installation.unpacking_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.UnpackingStartTo."
"CheckingExpectationsStart",
installation.checking_expectations_started_time.value() -
installation.unpacking_started_time.value());
}
if (installation.finalizing_started_time &&
installation.checking_expectations_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.CheckingExpectationsStartTo."
"FinalizingStart",
installation.finalizing_started_time.value() -
installation.checking_expectations_started_time.value());
}
if (installation.installation_complete_time &&
installation.finalizing_started_time) {
base::UmaHistogramLongTimes(
"Extensions.ForceInstalledTime.FinalizingStartTo."
"CRXInstallComplete",
installation.installation_complete_time.value() -
installation.finalizing_started_time.value());
}
} }
} }
if (missing_forced_extensions.empty()) { if (missing_forced_extensions.empty()) {
......
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