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

Side by Side Diff: content/browser/notifications/notification_event_dispatcher_impl.cc

Issue 2682353002: Mojoify the notificationclick and notificationclose events (Closed)
Patch Set: Mojoify the notificationclick and notificationclose events 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/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/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 "base/optional.h"
8 #include "build/build_config.h" 9 #include "build/build_config.h"
9 #include "content/browser/notifications/platform_notification_context_impl.h" 10 #include "content/browser/notifications/platform_notification_context_impl.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 11 #include "content/browser/service_worker/service_worker_context_wrapper.h"
11 #include "content/browser/service_worker/service_worker_registration.h" 12 #include "content/browser/service_worker/service_worker_registration.h"
12 #include "content/browser/service_worker/service_worker_storage.h" 13 #include "content/browser/service_worker/service_worker_storage.h"
13 #include "content/common/service_worker/service_worker_messages.h"
14 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/storage_partition.h" 16 #include "content/public/browser/storage_partition.h"
17 #include "content/public/common/platform_notification_data.h" 17 #include "content/public/common/platform_notification_data.h"
18 18
19 namespace content { 19 namespace content {
20 namespace { 20 namespace {
21 21
22 using NotificationDispatchCompleteCallback = 22 using NotificationDispatchCompleteCallback =
23 NotificationEventDispatcher::NotificationDispatchCompleteCallback; 23 NotificationEventDispatcher::NotificationDispatchCompleteCallback;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // the IO thread, and with the worker running. 201 // the IO thread, and with the worker running.
202 void DispatchNotificationClickEventOnWorker( 202 void DispatchNotificationClickEventOnWorker(
203 const scoped_refptr<ServiceWorkerVersion>& service_worker, 203 const scoped_refptr<ServiceWorkerVersion>& service_worker,
204 const NotificationDatabaseData& notification_database_data, 204 const NotificationDatabaseData& notification_database_data,
205 int action_index, 205 int action_index,
206 const base::NullableString16& reply, 206 const base::NullableString16& reply,
207 const ServiceWorkerVersion::StatusCallback& callback) { 207 const ServiceWorkerVersion::StatusCallback& callback) {
208 DCHECK_CURRENTLY_ON(BrowserThread::IO); 208 DCHECK_CURRENTLY_ON(BrowserThread::IO);
209 int request_id = service_worker->StartRequest( 209 int request_id = service_worker->StartRequest(
210 ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK, callback); 210 ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK, callback);
211 service_worker->DispatchSimpleEvent< 211
212 ServiceWorkerHostMsg_NotificationClickEventFinished>( 212 base::Optional<base::string16> optional_reply;
213 request_id, 213 if (!reply.is_null())
214 ServiceWorkerMsg_NotificationClickEvent( 214 optional_reply = reply.string();
215 request_id, notification_database_data.notification_id, 215
216 notification_database_data.notification_data, action_index, reply)); 216 service_worker->event_dispatcher()->DispatchNotificationClickEvent(
217 notification_database_data.notification_id,
218 notification_database_data.notification_data, action_index,
219 optional_reply, service_worker->CreateSimpleEventCallback(request_id));
217 } 220 }
218 221
219 // Dispatches the notification click event on the |service_worker_registration|. 222 // Dispatches the notification click event on the |service_worker_registration|.
220 void DoDispatchNotificationClickEvent( 223 void DoDispatchNotificationClickEvent(
221 int action_index, 224 int action_index,
222 const base::NullableString16& reply, 225 const base::NullableString16& reply,
223 const NotificationDispatchCompleteCallback& dispatch_complete_callback, 226 const NotificationDispatchCompleteCallback& dispatch_complete_callback,
224 const scoped_refptr<PlatformNotificationContext>& notification_context, 227 const scoped_refptr<PlatformNotificationContext>& notification_context,
225 const ServiceWorkerRegistration* service_worker_registration, 228 const ServiceWorkerRegistration* service_worker_registration,
226 const NotificationDatabaseData& notification_database_data) { 229 const NotificationDatabaseData& notification_database_data) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 273
271 // Dispatches the notificationclose event on |service_worker|. Must be called on 274 // Dispatches the notificationclose event on |service_worker|. Must be called on
272 // the IO thread, and with the worker running. 275 // the IO thread, and with the worker running.
273 void DispatchNotificationCloseEventOnWorker( 276 void DispatchNotificationCloseEventOnWorker(
274 const scoped_refptr<ServiceWorkerVersion>& service_worker, 277 const scoped_refptr<ServiceWorkerVersion>& service_worker,
275 const NotificationDatabaseData& notification_database_data, 278 const NotificationDatabaseData& notification_database_data,
276 const ServiceWorkerVersion::StatusCallback& callback) { 279 const ServiceWorkerVersion::StatusCallback& callback) {
277 DCHECK_CURRENTLY_ON(BrowserThread::IO); 280 DCHECK_CURRENTLY_ON(BrowserThread::IO);
278 int request_id = service_worker->StartRequest( 281 int request_id = service_worker->StartRequest(
279 ServiceWorkerMetrics::EventType::NOTIFICATION_CLOSE, callback); 282 ServiceWorkerMetrics::EventType::NOTIFICATION_CLOSE, callback);
280 service_worker->DispatchSimpleEvent< 283
281 ServiceWorkerHostMsg_NotificationCloseEventFinished>( 284 service_worker->event_dispatcher()->DispatchNotificationCloseEvent(
282 request_id, ServiceWorkerMsg_NotificationCloseEvent( 285 notification_database_data.notification_id,
283 request_id, notification_database_data.notification_id, 286 notification_database_data.notification_data,
284 notification_database_data.notification_data)); 287 service_worker->CreateSimpleEventCallback(request_id));
285 } 288 }
286 289
287 // Actually dispatches the notification close event on the service worker 290 // Actually dispatches the notification close event on the service worker
288 // registration. 291 // registration.
289 void DoDispatchNotificationCloseEvent( 292 void DoDispatchNotificationCloseEvent(
290 const std::string& notification_id, 293 const std::string& notification_id,
291 bool by_user, 294 bool by_user,
292 const NotificationDispatchCompleteCallback& dispatch_complete_callback, 295 const NotificationDispatchCompleteCallback& dispatch_complete_callback,
293 const scoped_refptr<PlatformNotificationContext>& notification_context, 296 const scoped_refptr<PlatformNotificationContext>& notification_context,
294 const ServiceWorkerRegistration* service_worker_registration, 297 const ServiceWorkerRegistration* service_worker_registration,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 bool by_user, 381 bool by_user,
379 const NotificationDispatchCompleteCallback& dispatch_complete_callback) { 382 const NotificationDispatchCompleteCallback& dispatch_complete_callback) {
380 DispatchNotificationEvent( 383 DispatchNotificationEvent(
381 browser_context, notification_id, origin, 384 browser_context, notification_id, origin,
382 base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user, 385 base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user,
383 dispatch_complete_callback), 386 dispatch_complete_callback),
384 dispatch_complete_callback); 387 dispatch_complete_callback);
385 } 388 }
386 389
387 } // namespace content 390 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698