Commit c2cbb827 authored by Saurabh Nijhara's avatar Saurabh Nijhara Committed by Commit Bot

Add CRX_FETCH_URL_EMPTY failure with empty info to misconfigurations

We get CRX_FETCH_URL_EMPTY failure reason with check status as noupdate
and empty info field when the extension being requested is no longer
being served by the Chrome Web Store and this can be considered as an
admin side misconfiguration.

Bug: 1063031
Change-Id: I61f2beca94ea38faa32b1539bff42318fce7a6a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306044
Commit-Queue: Saurabh Nijhara <snijhara@google.com>
Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792275}
parent 426b5f80
......@@ -27,6 +27,7 @@
namespace extensions {
using ExtensionStatus = ForceInstalledTracker::ExtensionStatus;
using FailureReason = InstallStageTracker::FailureReason;
namespace {
// Timeout to report UMA if not all force-installed extension were loaded.
......@@ -124,14 +125,22 @@ bool ForceInstalledMetrics::IsMisconfiguration(
// the device.
if (profile_->GetPrefs()->IsManagedPreference(arc::prefs::kArcEnabled) &&
profile_->GetPrefs()->GetBoolean(arc::prefs::kArcEnabled) &&
installation_data.failure_reason ==
InstallStageTracker::FailureReason::REPLACED_BY_ARC_APP)
installation_data.failure_reason == FailureReason::REPLACED_BY_ARC_APP) {
return true;
}
#endif // defined(OS_CHROMEOS)
if (installation_data.failure_reason ==
InstallStageTracker::FailureReason::NOT_PERFORMING_NEW_INSTALL)
FailureReason::NOT_PERFORMING_NEW_INSTALL) {
return true;
}
if (installation_data.failure_reason == FailureReason::CRX_FETCH_URL_EMPTY) {
DCHECK(installation_data.no_updates_info);
if (installation_data.no_updates_info.value() ==
InstallStageTracker::NoUpdatesInfo::kEmpty) {
return true;
}
}
return false;
}
......@@ -234,8 +243,7 @@ void ForceInstalledMetrics::ReportMetrics() {
installation.downloading_cache_status.value_or(
ExtensionDownloaderDelegate::CacheStatus::CACHE_UNKNOWN));
if (!installation.failure_reason && installation.install_stage) {
installation.failure_reason =
InstallStageTracker::FailureReason::IN_PROGRESS;
installation.failure_reason = FailureReason::IN_PROGRESS;
InstallStageTracker::Stage install_stage =
installation.install_stage.value();
base::UmaHistogramEnumeration("Extensions.ForceInstalledStage",
......@@ -250,9 +258,8 @@ void ForceInstalledMetrics::ReportMetrics() {
}
if (IsMisconfiguration(installation, extension_id))
misconfigured_extensions++;
InstallStageTracker::FailureReason failure_reason =
installation.failure_reason.value_or(
InstallStageTracker::FailureReason::UNKNOWN);
FailureReason failure_reason =
installation.failure_reason.value_or(FailureReason::UNKNOWN);
base::UmaHistogramEnumeration("Extensions.ForceInstalledFailureReason3",
failure_reason);
if (tracker_->extensions().at(extension_id).is_from_store) {
......@@ -265,8 +272,7 @@ void ForceInstalledMetrics::ReportMetrics() {
// In case of CRX_FETCH_FAILURE, report the network error code, HTTP
// error code and number of fetch tries made.
if (failure_reason ==
InstallStageTracker::FailureReason::CRX_FETCH_FAILED) {
if (failure_reason == FailureReason::CRX_FETCH_FAILED) {
base::UmaHistogramSparse("Extensions.ForceInstalledNetworkErrorCode",
installation.network_error_code.value());
......@@ -281,8 +287,7 @@ void ForceInstalledMetrics::ReportMetrics() {
// In case of MANIFEST_FETCH_FAILURE, report the network error code,
// HTTP error code and number of fetch tries made.
if (failure_reason ==
InstallStageTracker::FailureReason::MANIFEST_FETCH_FAILED) {
if (failure_reason == FailureReason::MANIFEST_FETCH_FAILED) {
base::UmaHistogramSparse(
"Extensions.ForceInstalledManifestFetchFailedNetworkErrorCode",
installation.network_error_code.value());
......@@ -320,8 +325,7 @@ void ForceInstalledMetrics::ReportMetrics() {
installation.unpacker_failure_reason.value(),
SandboxedUnpackerFailureReason::NUM_FAILURE_REASONS);
}
if (failure_reason ==
InstallStageTracker::FailureReason::CRX_FETCH_URL_EMPTY) {
if (failure_reason == FailureReason::CRX_FETCH_URL_EMPTY) {
if (installation.update_check_status) {
base::UmaHistogramEnumeration(
"Extensions.ForceInstalledFailureUpdateCheckStatus",
......@@ -335,8 +339,7 @@ void ForceInstalledMetrics::ReportMetrics() {
installation.no_updates_info.value());
}
if (installation.manifest_invalid_error) {
DCHECK_EQ(failure_reason,
InstallStageTracker::FailureReason::MANIFEST_INVALID);
DCHECK_EQ(failure_reason, FailureReason::MANIFEST_INVALID);
base::UmaHistogramEnumeration(
"Extensions.ForceInstalledFailureManifestInvalidErrorDetail2",
installation.manifest_invalid_error.value());
......
......@@ -540,15 +540,14 @@ TEST_F(ForceInstalledMetricsTest,
1);
}
// Reporting SandboxedUnpackerFailureReason when the force installed extension
// fails to install with error CRX_INSTALL_ERROR_SANDBOXED_UNPACKER_FAILURE.
// Reporting update check status when the force installed extension
// fails to install with error CRX_FETCH_URL_EMPTY.
TEST_F(ForceInstalledMetricsTest, ExtensionsUpdateCheckStatusReporting) {
SetupForceList();
install_stage_tracker_->ReportManifestUpdateCheckStatus(kExtensionId1, "ok");
install_stage_tracker_->ReportInfoOnNoUpdatesFailure(kExtensionId1, "");
install_stage_tracker_->ReportFailure(
kExtensionId1, InstallStageTracker::FailureReason::CRX_FETCH_URL_EMPTY);
auto extension =
ExtensionBuilder(kExtensionName1).SetID(kExtensionId1).Build();
tracker_->OnExtensionLoaded(profile_, extension.get());
install_stage_tracker_->ReportManifestUpdateCheckStatus(kExtensionId2,
"noupdate");
......@@ -558,10 +557,7 @@ TEST_F(ForceInstalledMetricsTest, ExtensionsUpdateCheckStatusReporting) {
// ForceInstalledMetrics shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectTotalCount(kManifestUpdateCheckStatus, 2);
histogram_tester_.ExpectBucketCount(
kManifestUpdateCheckStatus, InstallStageTracker::UpdateCheckStatus::kOk,
1);
histogram_tester_.ExpectTotalCount(kManifestUpdateCheckStatus, 1);
histogram_tester_.ExpectBucketCount(
kManifestUpdateCheckStatus,
InstallStageTracker::UpdateCheckStatus::kNoUpdate, 1);
......@@ -998,6 +994,48 @@ TEST_F(ForceInstalledMetricsTest,
1);
}
// Session in which either all the extensions installed successfully, or all
// failures are admin-side misconfigurations. This test verifies that failure
// CRX_FETCH_URL_EMPTY with empty info field is considered as misconfiguration.
TEST_F(ForceInstalledMetricsTest,
NonMisconfigurationFailureNotPresentCrxFetchUrlEmptyError) {
SetupForceList();
auto extension =
ExtensionBuilder(kExtensionName1).SetID(kExtensionId1).Build();
tracker_->OnExtensionLoaded(profile_, extension.get());
install_stage_tracker_->ReportManifestUpdateCheckStatus(kExtensionId2,
"noupdate");
install_stage_tracker_->ReportInfoOnNoUpdatesFailure(kExtensionId2, "");
install_stage_tracker_->ReportFailure(
kExtensionId2, InstallStageTracker::FailureReason::CRX_FETCH_URL_EMPTY);
// ForceInstalledMetrics shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectBucketCount(kPossibleNonMisconfigurationFailures, 0,
1);
}
// This test verifies that failure CRX_FETCH_URL_EMPTY with non empty info field
// is not considered as a misconfiguration.
TEST_F(ForceInstalledMetricsTest,
NonMisconfigurationFailurePresentCrxFetchUrlEmptyError) {
SetupForceList();
auto extension =
ExtensionBuilder(kExtensionName1).SetID(kExtensionId1).Build();
tracker_->OnExtensionLoaded(profile_, extension.get());
install_stage_tracker_->ReportManifestUpdateCheckStatus(kExtensionId2,
"noupdate");
install_stage_tracker_->ReportInfoOnNoUpdatesFailure(kExtensionId2,
"rate limit");
install_stage_tracker_->ReportFailure(
kExtensionId2, InstallStageTracker::FailureReason::CRX_FETCH_URL_EMPTY);
// ForceInstalledMetrics shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectBucketCount(kPossibleNonMisconfigurationFailures, 0,
0);
}
TEST_F(ForceInstalledMetricsTest, NoExtensionsConfigured) {
EXPECT_TRUE(fake_timer_->IsRunning());
fake_timer_->Fire();
......
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