Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1330)

Unified Diff: content/browser/service_worker/service_worker_metrics.cc

Issue 1178043002: Update ServiceWorker event handled status histogram (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_metrics.cc
diff --git a/content/browser/service_worker/service_worker_metrics.cc b/content/browser/service_worker/service_worker_metrics.cc
index ec85f029ef52a7266d70a20ce65b553e255dae2b..8709b11ddc03731bf8ec2ce88dac48ae33c088c3 100644
--- a/content/browser/service_worker/service_worker_metrics.cc
+++ b/content/browser/service_worker/service_worker_metrics.cc
@@ -6,6 +6,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics_action.h"
+#include "base/strings/string_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/user_metrics.h"
@@ -21,6 +22,25 @@ void RecordURLMetricOnUI(const GURL& url) {
"ServiceWorker.ControlledPageUrl", url);
}
+bool ShouldExcludeForHistogram(const GURL& scope) {
+ // Exclude NTP scope from UMA for now as it tends to dominate the stats
+ // and makes the results largely skewed.
+ // TOOD(kinuko): This should be temporary, revisit this once we have
+ // better idea about what should be excluded in the UMA.
+ // (UIThreadSearchTermsData::GoogleBaseURLValue() returns the google base
+ // URL, but not available in content layer)
+ const char google_like_scope_prefix[] = "https://www.google.";
+ return base::StartsWith(scope.spec(), google_like_scope_prefix,
+ base::CompareCase::INSENSITIVE_ASCII);
+}
+
+enum EventHandledRatioType {
+ EVENT_HANDLED_NONE,
+ EVENT_HANDLED_SOME,
+ EVENT_HANDLED_ALL,
+ NUM_EVENT_HANDLED_RATIO_TYPE,
+};
+
} // namespace
void ServiceWorkerMetrics::CountInitDiskCacheResult(bool result) {
@@ -122,13 +142,21 @@ void ServiceWorkerMetrics::RecordInstallEventStatus(
SERVICE_WORKER_ERROR_MAX_VALUE);
}
-void ServiceWorkerMetrics::RecordEventStatus(size_t fired_events,
- size_t handled_events) {
- if (!fired_events)
+void ServiceWorkerMetrics::RecordEventHandledRatio(const GURL& scope,
+ EventType event,
+ size_t handled_events,
+ size_t fired_events) {
+ if (!fired_events || ShouldExcludeForHistogram(scope))
return;
- int unhandled_ratio = (fired_events - handled_events) * 100 / fired_events;
- UMA_HISTOGRAM_PERCENTAGE("ServiceWorker.UnhandledEventRatio",
- unhandled_ratio);
+ EventHandledRatioType type = EVENT_HANDLED_SOME;
+ if (fired_events == handled_events)
+ type = EVENT_HANDLED_ALL;
+ else if (handled_events == 0)
+ type = EVENT_HANDLED_NONE;
+ // For now Fetch is the only type that is recorded.
+ DCHECK_EQ(EVENT_TYPE_FETCH, event);
+ UMA_HISTOGRAM_ENUMERATION("ServiceWorker.EventHandledRatioType.Fetch", type,
+ NUM_EVENT_HANDLED_RATIO_TYPE);
}
void ServiceWorkerMetrics::RecordFetchEventStatus(
« no previous file with comments | « content/browser/service_worker/service_worker_metrics.h ('k') | content/browser/service_worker/service_worker_version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698