Commit 5816fe6f authored by Swapnil's avatar Swapnil Committed by Commit Bot

[Refactoring] Report error codes using 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 new
methods to report error codes for force installed extensions when the
failure reason is either MANIFEST_FETCH_FAILED or CRX_FETCH_FAILED.

Bug: 1127851
Change-Id: I4e3d0ac6c393a4f1af14a5979c80f08641159ee9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409960Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Cr-Commit-Position: refs/heads/master@{#807404}
parent 21f772b0
...@@ -31,6 +31,19 @@ namespace { ...@@ -31,6 +31,19 @@ namespace {
constexpr base::TimeDelta kInstallationTimeout = constexpr base::TimeDelta kInstallationTimeout =
base::TimeDelta::FromMinutes(5); base::TimeDelta::FromMinutes(5);
constexpr char kManifestFetchFailedNetworkErrorCode[] =
"Extensions.ForceInstalledManifestFetchFailedNetworkErrorCode";
constexpr char kManifestFetchFailedHttpErrorCode[] =
"Extensions.ForceInstalledManifestFetchFailedHttpErrorCode2";
constexpr char kManifestFetchFailedFetchTries[] =
"Extensions.ForceInstalledManifestFetchFailedFetchTries";
constexpr char kCrxFetchFailedNetworkErrorCode[] =
"Extensions.ForceInstalledNetworkErrorCode";
constexpr char kCrxFetchFailedHttpErrorCode[] =
"Extensions.ForceInstalledHttpErrorCode2";
constexpr char kCrxFetchFailedFetchTries[] =
"Extensions.ForceInstalledFetchTries";
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Helper method to convert user_manager::UserType to // Helper method to convert user_manager::UserType to
// InstallStageTracker::UserType for histogram purposes. // InstallStageTracker::UserType for histogram purposes.
...@@ -129,6 +142,25 @@ void ReportInstallationStageTimes( ...@@ -129,6 +142,25 @@ void ReportInstallationStageTimes(
} }
} }
// Reports the network error code, HTTP error code and number of fetch tries
// made when extension fails to install with MANIFEST_FETCH_FAILED or
// CRX_FETCH_FAILED.
void ReportErrorCodes(const InstallStageTracker::InstallationData& installation,
const std::string& network_error_code_histogram,
const std::string& http_error_code_histogram,
const std::string& fetch_tries_histogram) {
base::UmaHistogramSparse(network_error_code_histogram,
installation.network_error_code.value());
if (installation.response_code) {
base::UmaHistogramSparse(http_error_code_histogram,
installation.response_code.value());
}
base::UmaHistogramExactLinear(fetch_tries_histogram,
installation.fetch_tries.value(),
ExtensionDownloader::kMaxRetries);
}
} // namespace } // namespace
ForceInstalledMetrics::ForceInstalledMetrics( ForceInstalledMetrics::ForceInstalledMetrics(
...@@ -264,35 +296,17 @@ void ForceInstalledMetrics::ReportMetrics() { ...@@ -264,35 +296,17 @@ void ForceInstalledMetrics::ReportMetrics() {
// In case of CRX_FETCH_FAILURE, report the network error code, HTTP // In case of CRX_FETCH_FAILURE, report the network error code, HTTP
// error code and number of fetch tries made. // error code and number of fetch tries made.
if (failure_reason == FailureReason::CRX_FETCH_FAILED) { if (failure_reason == FailureReason::CRX_FETCH_FAILED)
base::UmaHistogramSparse("Extensions.ForceInstalledNetworkErrorCode", ReportErrorCodes(installation, kCrxFetchFailedNetworkErrorCode,
installation.network_error_code.value()); kCrxFetchFailedHttpErrorCode, kCrxFetchFailedFetchTries);
if (installation.response_code) {
base::UmaHistogramSparse("Extensions.ForceInstalledHttpErrorCode2",
installation.response_code.value());
}
base::UmaHistogramExactLinear("Extensions.ForceInstalledFetchTries",
installation.fetch_tries.value(),
ExtensionDownloader::kMaxRetries);
}
// In case of MANIFEST_FETCH_FAILURE, report the network error code, // In case of MANIFEST_FETCH_FAILURE, report the network error code,
// HTTP error code and number of fetch tries made. // HTTP error code and number of fetch tries made.
if (failure_reason == FailureReason::MANIFEST_FETCH_FAILED) { if (failure_reason == FailureReason::MANIFEST_FETCH_FAILED)
base::UmaHistogramSparse( ReportErrorCodes(installation, kManifestFetchFailedNetworkErrorCode,
"Extensions.ForceInstalledManifestFetchFailedNetworkErrorCode", kManifestFetchFailedHttpErrorCode,
installation.network_error_code.value()); kManifestFetchFailedFetchTries);
if (installation.response_code) {
base::UmaHistogramSparse(
"Extensions.ForceInstalledManifestFetchFailedHttpErrorCode2",
installation.response_code.value());
}
base::UmaHistogramExactLinear(
"Extensions.ForceInstalledManifestFetchFailedFetchTries",
installation.fetch_tries.value(), ExtensionDownloader::kMaxRetries);
}
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Report type of user in case Force Installed Extensions fail to // Report type of user in case Force Installed Extensions fail to
// install only if there is a user corresponding to given profile. There can // install only if there is a user corresponding to given profile. There can
......
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