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

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

Issue 2689693003: Add a helper method to create SW SimpleEventCallbacks. (Closed)
Patch Set: Add a helper method to create SW SimpleEventCallbacks. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_dispatcher_host.cc » ('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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
127 service_worker->event_dispatcher()->DispatchPushEvent( 127 service_worker->event_dispatcher()->DispatchPushEvent(
128 payload, base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished, 128 payload, service_worker->CreateSimpleEventCallback(request_id));
129 service_worker, request_id));
130 } 129 }
131 130
132 // static 131 // static
133 void PushMessagingRouter::DeliverMessageEnd( 132 void PushMessagingRouter::DeliverMessageEnd(
134 const DeliverMessageCallback& deliver_message_callback, 133 const DeliverMessageCallback& deliver_message_callback,
135 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, 134 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration,
136 ServiceWorkerStatusCode service_worker_status) { 135 ServiceWorkerStatusCode service_worker_status) {
137 DCHECK_CURRENTLY_ON(BrowserThread::IO); 136 DCHECK_CURRENTLY_ON(BrowserThread::IO);
138 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent", 137 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent",
139 service_worker_status, 138 service_worker_status,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 case SERVICE_WORKER_ERROR_MAX_VALUE: 170 case SERVICE_WORKER_ERROR_MAX_VALUE:
172 NOTREACHED() << "Got unexpected error code: " << service_worker_status 171 NOTREACHED() << "Got unexpected error code: " << service_worker_status
173 << " " << ServiceWorkerStatusToString(service_worker_status); 172 << " " << ServiceWorkerStatusToString(service_worker_status);
174 delivery_status = PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR; 173 delivery_status = PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR;
175 break; 174 break;
176 } 175 }
177 RunDeliverCallback(deliver_message_callback, delivery_status); 176 RunDeliverCallback(deliver_message_callback, delivery_status);
178 } 177 }
179 178
180 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698