OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/push_messaging/push_messaging_router.h" | 5 #include "content/browser/push_messaging/push_messaging_router.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, | 116 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, |
117 const PushEventPayload& payload, | 117 const PushEventPayload& payload, |
118 const DeliverMessageCallback& deliver_message_callback) { | 118 const DeliverMessageCallback& deliver_message_callback) { |
119 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 119 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
120 int request_id = service_worker->StartRequestWithCustomTimeout( | 120 int request_id = service_worker->StartRequestWithCustomTimeout( |
121 ServiceWorkerMetrics::EventType::PUSH, | 121 ServiceWorkerMetrics::EventType::PUSH, |
122 base::Bind(&PushMessagingRouter::DeliverMessageEnd, | 122 base::Bind(&PushMessagingRouter::DeliverMessageEnd, |
123 deliver_message_callback, service_worker_registration), | 123 deliver_message_callback, service_worker_registration), |
124 base::TimeDelta::FromSeconds(kPushMessageTimeoutSeconds), | 124 base::TimeDelta::FromSeconds(kPushMessageTimeoutSeconds), |
125 ServiceWorkerVersion::KILL_ON_TIMEOUT); | 125 ServiceWorkerVersion::KILL_ON_TIMEOUT); |
126 | 126 service_worker->DispatchSimpleEvent<ServiceWorkerHostMsg_PushEventFinished>( |
127 service_worker->event_dispatcher()->DispatchPushEvent( | 127 request_id, ServiceWorkerMsg_PushEvent(request_id, payload)); |
128 payload, base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished, | |
129 service_worker, request_id)); | |
130 } | 128 } |
131 | 129 |
132 // static | 130 // static |
133 void PushMessagingRouter::DeliverMessageEnd( | 131 void PushMessagingRouter::DeliverMessageEnd( |
134 const DeliverMessageCallback& deliver_message_callback, | 132 const DeliverMessageCallback& deliver_message_callback, |
135 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, | 133 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, |
136 ServiceWorkerStatusCode service_worker_status) { | 134 ServiceWorkerStatusCode service_worker_status) { |
137 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 135 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
138 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent", | 136 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent", |
139 service_worker_status, | 137 service_worker_status, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 case SERVICE_WORKER_ERROR_MAX_VALUE: | 169 case SERVICE_WORKER_ERROR_MAX_VALUE: |
172 NOTREACHED() << "Got unexpected error code: " << service_worker_status | 170 NOTREACHED() << "Got unexpected error code: " << service_worker_status |
173 << " " << ServiceWorkerStatusToString(service_worker_status); | 171 << " " << ServiceWorkerStatusToString(service_worker_status); |
174 delivery_status = PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR; | 172 delivery_status = PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR; |
175 break; | 173 break; |
176 } | 174 } |
177 RunDeliverCallback(deliver_message_callback, delivery_status); | 175 RunDeliverCallback(deliver_message_callback, delivery_status); |
178 } | 176 } |
179 | 177 |
180 } // namespace content | 178 } // namespace content |
OLD | NEW |