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); |