| 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..740a1f74d6a45d39b27e67553556132e756a780d 100644
|
| --- a/content/browser/service_worker/service_worker_version.cc
|
| +++ b/content/browser/service_worker/service_worker_version.cc
|
| @@ -366,6 +366,23 @@ bool IsInstalled(ServiceWorkerVersion::Status status) {
|
| const int ServiceWorkerVersion::kStartWorkerTimeoutMinutes = 5;
|
| const int ServiceWorkerVersion::kRequestTimeoutMinutes = 5;
|
|
|
| +class ServiceWorkerVersion::ServiceWorkerEventMetrics {
|
| + public:
|
| + ServiceWorkerEventMetrics() {}
|
| + ~ServiceWorkerEventMetrics() {
|
| + ServiceWorkerEventMetrics::RecordEventStatus(fired_events, handled_events);
|
| + }
|
| +
|
| + void RecordEventStatus(bool handled) {
|
| + ++fired_events;
|
| + if (handled)
|
| + ++handled_events;
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(ServiceWorkerEventMetrics);
|
| +};
|
| +
|
| ServiceWorkerVersion::ServiceWorkerVersion(
|
| ServiceWorkerRegistration* registration,
|
| const GURL& script_url,
|
| @@ -379,6 +396,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 +1203,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);
|
|
|