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/notifications/notification_event_dispatcher_impl.h" | 5 #include "content/browser/notifications/notification_event_dispatcher_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/browser/notifications/platform_notification_context_impl.h" | 9 #include "content/browser/notifications/platform_notification_context_impl.h" |
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const scoped_refptr<PlatformNotificationContext>& notification_context, | 225 const scoped_refptr<PlatformNotificationContext>& notification_context, |
226 const ServiceWorkerRegistration* service_worker_registration, | 226 const ServiceWorkerRegistration* service_worker_registration, |
227 const NotificationDatabaseData& notification_database_data) { | 227 const NotificationDatabaseData& notification_database_data) { |
228 ServiceWorkerVersion::StatusCallback status_callback = base::Bind( | 228 ServiceWorkerVersion::StatusCallback status_callback = base::Bind( |
229 &ServiceWorkerNotificationEventFinished, dispatch_complete_callback); | 229 &ServiceWorkerNotificationEventFinished, dispatch_complete_callback); |
230 service_worker_registration->active_version()->RunAfterStartWorker( | 230 service_worker_registration->active_version()->RunAfterStartWorker( |
231 base::Bind( | 231 base::Bind( |
232 &DispatchNotificationClickEventOnWorker, | 232 &DispatchNotificationClickEventOnWorker, |
233 make_scoped_refptr(service_worker_registration->active_version()), | 233 make_scoped_refptr(service_worker_registration->active_version()), |
234 notification_database_data, action_index, status_callback), | 234 notification_database_data, action_index, status_callback), |
235 status_callback); | 235 status_callback, ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK); |
236 } | 236 } |
237 | 237 |
238 // ----------------------------------------------------------------------------- | 238 // ----------------------------------------------------------------------------- |
239 | 239 |
240 // Called when the notification data has been deleted to finish the notification | 240 // Called when the notification data has been deleted to finish the notification |
241 // close event. | 241 // close event. |
242 void OnPersistentNotificationDataDeleted( | 242 void OnPersistentNotificationDataDeleted( |
243 ServiceWorkerStatusCode service_worker_status, | 243 ServiceWorkerStatusCode service_worker_status, |
244 const NotificationDispatchCompleteCallback& dispatch_complete_callback, | 244 const NotificationDispatchCompleteCallback& dispatch_complete_callback, |
245 bool success) { | 245 bool success) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 base::Bind(&DeleteNotificationDataFromDatabase, | 296 base::Bind(&DeleteNotificationDataFromDatabase, |
297 notification_database_data.notification_id, | 297 notification_database_data.notification_id, |
298 notification_database_data.origin, notification_context, | 298 notification_database_data.origin, notification_context, |
299 dispatch_complete_callback); | 299 dispatch_complete_callback); |
300 if (by_user) { | 300 if (by_user) { |
301 service_worker_registration->active_version()->RunAfterStartWorker( | 301 service_worker_registration->active_version()->RunAfterStartWorker( |
302 base::Bind( | 302 base::Bind( |
303 &DispatchNotificationCloseEventOnWorker, | 303 &DispatchNotificationCloseEventOnWorker, |
304 make_scoped_refptr(service_worker_registration->active_version()), | 304 make_scoped_refptr(service_worker_registration->active_version()), |
305 notification_database_data, dispatch_event_callback), | 305 notification_database_data, dispatch_event_callback), |
306 dispatch_event_callback); | 306 dispatch_event_callback, |
| 307 ServiceWorkerMetrics::EventType::NOTIFICATION_CLOSE); |
307 } else { | 308 } else { |
308 dispatch_event_callback.Run(ServiceWorkerStatusCode::SERVICE_WORKER_OK); | 309 dispatch_event_callback.Run(ServiceWorkerStatusCode::SERVICE_WORKER_OK); |
309 } | 310 } |
310 } | 311 } |
311 | 312 |
312 // Dispatches any notification event. The actual, specific event dispatch should | 313 // Dispatches any notification event. The actual, specific event dispatch should |
313 // be done by the |notification_action_callback|. | 314 // be done by the |notification_action_callback|. |
314 void DispatchNotificationEvent( | 315 void DispatchNotificationEvent( |
315 BrowserContext* browser_context, | 316 BrowserContext* browser_context, |
316 int64_t persistent_notification_id, | 317 int64_t persistent_notification_id, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 const GURL& origin, | 376 const GURL& origin, |
376 bool by_user, | 377 bool by_user, |
377 const NotificationDispatchCompleteCallback& dispatch_complete_callback) { | 378 const NotificationDispatchCompleteCallback& dispatch_complete_callback) { |
378 DispatchNotificationEvent(browser_context, persistent_notification_id, origin, | 379 DispatchNotificationEvent(browser_context, persistent_notification_id, origin, |
379 base::Bind(&DoDispatchNotificationCloseEvent, | 380 base::Bind(&DoDispatchNotificationCloseEvent, |
380 by_user, dispatch_complete_callback), | 381 by_user, dispatch_complete_callback), |
381 dispatch_complete_callback); | 382 dispatch_complete_callback); |
382 } | 383 } |
383 | 384 |
384 } // namespace content | 385 } // namespace content |
OLD | NEW |