Commit 1e01124f authored by Swapnil's avatar Swapnil Committed by Commit Bot

Add UMA to record whether the extension is from cache or not

We want to investigate why the force installed extensions fail to
install with error CRX_HEADER_INVALID. This CL adds UMA statistics
to record whether the extension is downloaded from cache or not when
extension fails with CRX_HEADER_INVALID error to get more details
about it.

New histogram added:
"Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsFromCache"

Bug: b/170087934
Change-Id: I843e4a1c2cce87b3975e2ad426f9b8177a744878
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2460734Reviewed-by: default avatarSaurabh Nijhara <snijhara@google.com>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Cr-Commit-Position: refs/heads/master@{#816786}
parent bfb7113b
...@@ -78,6 +78,15 @@ ForceInstalledMetrics::UserType ConvertUserType( ...@@ -78,6 +78,15 @@ ForceInstalledMetrics::UserType ConvertUserType(
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// Returns true if the extension is fetched from the cache.
bool IsExtensionFetchedFromCache(
const base::Optional<ExtensionDownloaderDelegate::CacheStatus> status) {
DCHECK(status);
return status.value() == ExtensionDownloaderDelegate::CacheStatus::
CACHE_HIT_ON_MANIFEST_FETCH_FAILURE ||
status.value() == ExtensionDownloaderDelegate::CacheStatus::CACHE_HIT;
}
// Reports time taken for force installed extension during different // Reports time taken for force installed extension during different
// installation stages. // installation stages.
void ReportInstallationStageTimes( void ReportInstallationStageTimes(
...@@ -240,6 +249,9 @@ void ReportDetailedFailureReasons( ...@@ -240,6 +249,9 @@ void ReportDetailedFailureReasons(
base::UmaHistogramBoolean( base::UmaHistogramBoolean(
"Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsCWS", "Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsCWS",
is_from_store); is_from_store);
base::UmaHistogramBoolean(
"Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsFromCache",
IsExtensionFetchedFromCache(installation.downloading_cache_status));
} }
} }
......
...@@ -113,6 +113,8 @@ constexpr char kFinalizingTimeStats[] = ...@@ -113,6 +113,8 @@ constexpr char kFinalizingTimeStats[] =
"Extensions.ForceInstalledTime.FinalizingStartTo.CRXInstallComplete"; "Extensions.ForceInstalledTime.FinalizingStartTo.CRXInstallComplete";
constexpr char kCrxHeaderInvalidFailureIsCWS[] = constexpr char kCrxHeaderInvalidFailureIsCWS[] =
"Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsCWS"; "Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsCWS";
constexpr char kCrxHeaderInvalidFailureFromCache[] =
"Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsFromCache";
} // namespace } // namespace
...@@ -533,10 +535,12 @@ TEST_F(ForceInstalledMetricsTest, ...@@ -533,10 +535,12 @@ TEST_F(ForceInstalledMetricsTest,
1); 1);
} }
// Reporting whether the extension is from CWS or not when the force installed // Reporting when the extension is downloaded from cache and it fails to install
// extension fails to install with error CRX_HEADER_INVALID. // with error CRX_HEADER_INVALID.
TEST_F(ForceInstalledMetricsTest, ExtensionsCrxHeaderInvalid) { TEST_F(ForceInstalledMetricsTest, ExtensionsCrxHeaderInvalidFromCache) {
SetupForceList(); SetupForceList();
install_stage_tracker()->ReportDownloadingCacheStatus(
kExtensionId1, ExtensionDownloaderDelegate::CacheStatus::CACHE_HIT);
install_stage_tracker()->ReportSandboxedUnpackerFailureReason( install_stage_tracker()->ReportSandboxedUnpackerFailureReason(
kExtensionId1, SandboxedUnpackerFailureReason::CRX_HEADER_INVALID); kExtensionId1, SandboxedUnpackerFailureReason::CRX_HEADER_INVALID);
auto ext2 = ExtensionBuilder(kExtensionName2).SetID(kExtensionId2).Build(); auto ext2 = ExtensionBuilder(kExtensionName2).SetID(kExtensionId2).Build();
...@@ -550,6 +554,31 @@ TEST_F(ForceInstalledMetricsTest, ExtensionsCrxHeaderInvalid) { ...@@ -550,6 +554,31 @@ TEST_F(ForceInstalledMetricsTest, ExtensionsCrxHeaderInvalid) {
kSandboxUnpackFailureReason, kSandboxUnpackFailureReason,
SandboxedUnpackerFailureReason::CRX_HEADER_INVALID, 1); SandboxedUnpackerFailureReason::CRX_HEADER_INVALID, 1);
histogram_tester_.ExpectBucketCount(kCrxHeaderInvalidFailureIsCWS, true, 1); histogram_tester_.ExpectBucketCount(kCrxHeaderInvalidFailureIsCWS, true, 1);
histogram_tester_.ExpectBucketCount(kCrxHeaderInvalidFailureFromCache, true,
1);
}
// Reporting when the extension is not downloaded from cache and it fails to
// install with error CRX_HEADER_INVALID.
TEST_F(ForceInstalledMetricsTest, ExtensionsCrxHeaderInvalidNotFromCache) {
SetupForceList();
install_stage_tracker()->ReportDownloadingCacheStatus(
kExtensionId1, ExtensionDownloaderDelegate::CacheStatus::CACHE_MISS);
install_stage_tracker()->ReportSandboxedUnpackerFailureReason(
kExtensionId1, SandboxedUnpackerFailureReason::CRX_HEADER_INVALID);
auto ext2 = ExtensionBuilder(kExtensionName2).SetID(kExtensionId2).Build();
registry()->AddEnabled(ext2.get());
force_installed_tracker()->OnExtensionLoaded(profile(), ext2.get());
// ForceInstalledMetrics shuts down timer because all extension are either
// loaded or failed.
EXPECT_FALSE(fake_timer_->IsRunning());
histogram_tester_.ExpectTotalCount(kSandboxUnpackFailureReason, 1);
histogram_tester_.ExpectBucketCount(
kSandboxUnpackFailureReason,
SandboxedUnpackerFailureReason::CRX_HEADER_INVALID, 1);
histogram_tester_.ExpectBucketCount(kCrxHeaderInvalidFailureIsCWS, true, 1);
histogram_tester_.ExpectBucketCount(kCrxHeaderInvalidFailureFromCache, false,
1);
} }
// Reporting info when the force installed extension fails to install with error // Reporting info when the force installed extension fails to install with error
......
...@@ -1483,6 +1483,21 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -1483,6 +1483,21 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram
name="Extensions.ForceInstalledFailureWithCrxHeaderInvalidIsFromCache"
enum="BooleanCacheHit" expires_after="2021-01-24">
<owner>swapnilgupta@google.com</owner>
<owner>burunduk@chromium.org</owner>
<owner>snijhara@google.com</owner>
<owner>managed-devices@google.com</owner>
<summary>
Records whether the extension is downloaded from cache or not. Recorded for
each forced extension that failed to install after 5 minutes with
Extensions.ForceInstalledFailureSandboxUnpackFailureReason equal to
CRX_HEADER_INVALID.
</summary>
</histogram>
<histogram name="Extensions.ForceInstalledFetchTries" units="retries" <histogram name="Extensions.ForceInstalledFetchTries" units="retries"
expires_after="2021-03-28"> expires_after="2021-03-28">
<owner>burunduk@chromium.org</owner> <owner>burunduk@chromium.org</owner>
......
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