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

Side by Side Diff: content/browser/push_messaging/push_messaging_router.cc

Issue 2569993002: [ServiceWorker] Mojofy PushEvent of Service Worker. (Closed)
Patch Set: Rebase and address comments from Peter and Marijn Created 4 years 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 unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | content/browser/service_worker/embedded_worker_test_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 service_worker->DispatchSimpleEvent<ServiceWorkerHostMsg_PushEventFinished>( 126
127 request_id, ServiceWorkerMsg_PushEvent(request_id, payload)); 127 service_worker->event_dispatcher()->DispatchPushEvent(
128 payload, base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished,
129 service_worker, request_id));
128 } 130 }
129 131
130 // static 132 // static
131 void PushMessagingRouter::DeliverMessageEnd( 133 void PushMessagingRouter::DeliverMessageEnd(
132 const DeliverMessageCallback& deliver_message_callback, 134 const DeliverMessageCallback& deliver_message_callback,
133 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, 135 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration,
134 ServiceWorkerStatusCode service_worker_status) { 136 ServiceWorkerStatusCode service_worker_status) {
135 DCHECK_CURRENTLY_ON(BrowserThread::IO); 137 DCHECK_CURRENTLY_ON(BrowserThread::IO);
136 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent", 138 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent",
137 service_worker_status, 139 service_worker_status,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 case SERVICE_WORKER_ERROR_MAX_VALUE: 171 case SERVICE_WORKER_ERROR_MAX_VALUE:
170 NOTREACHED() << "Got unexpected error code: " << service_worker_status 172 NOTREACHED() << "Got unexpected error code: " << service_worker_status
171 << " " << ServiceWorkerStatusToString(service_worker_status); 173 << " " << ServiceWorkerStatusToString(service_worker_status);
172 delivery_status = PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR; 174 delivery_status = PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR;
173 break; 175 break;
174 } 176 }
175 RunDeliverCallback(deliver_message_callback, delivery_status); 177 RunDeliverCallback(deliver_message_callback, delivery_status);
176 } 178 }
177 179
178 } // namespace content 180 } // namespace content
OLDNEW
« no previous file with comments | « AUTHORS ('k') | content/browser/service_worker/embedded_worker_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698