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

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

Issue 1133853007: Add UMA to record the ratio of how many fetch events are not handled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comment Created 5 years, 7 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
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_version.cc
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index 9504befa051be62a2107d6d13ce6525445130254..4299a26cbd2474f5077046f9852bc639a4601c13 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -366,6 +366,25 @@ bool IsInstalled(ServiceWorkerVersion::Status status) {
const int ServiceWorkerVersion::kStartWorkerTimeoutMinutes = 5;
const int ServiceWorkerVersion::kRequestTimeoutMinutes = 5;
+class ServiceWorkerVersion::ServiceWorkerEventMetrics {
+ public:
+ ServiceWorkerEventMetrics() {}
+ ~ServiceWorkerEventMetrics() {
+ ServiceWorkerMetrics::RecordEventStatus(fired_events, handled_events);
+ }
+
+ void RecordEventStatus(bool handled) {
+ ++fired_events;
+ if (handled)
+ ++handled_events;
+ }
+
+ private:
+ size_t fired_events = 0;
+ size_t handled_events = 0;
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerEventMetrics);
+};
+
ServiceWorkerVersion::ServiceWorkerVersion(
ServiceWorkerRegistration* registration,
const GURL& script_url,
@@ -379,6 +398,7 @@ ServiceWorkerVersion::ServiceWorkerVersion(
context_(context),
script_cache_map_(this, context),
ping_state_(NOT_PINGING),
+ metrics_(new ServiceWorkerEventMetrics),
weak_factory_(this) {
DCHECK(context_);
DCHECK(registration);
@@ -1185,6 +1205,10 @@ void ServiceWorkerVersion::OnFetchEventFinished(
return;
}
+ // TODO(kinuko): Record other event statuses too.
+ const bool handled = (result == SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE);
+ metrics_->RecordEventStatus(handled);
+
scoped_refptr<ServiceWorkerVersion> protect(this);
callback->Run(SERVICE_WORKER_OK, result, response);
RemoveCallbackAndStopIfRedundant(&fetch_callbacks_, request_id);
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698