| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/push_messaging/push_messaging_notification_manager.h" | 5 #include "chrome/browser/push_messaging/push_messaging_notification_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <bitset> | 9 #include <bitset> |
| 10 | 10 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 message_handled_closure))); | 285 message_handled_closure))); |
| 286 } | 286 } |
| 287 | 287 |
| 288 // static | 288 // static |
| 289 void PushMessagingNotificationManager::DidWriteNotificationDataIOProxy( | 289 void PushMessagingNotificationManager::DidWriteNotificationDataIOProxy( |
| 290 const base::WeakPtr<PushMessagingNotificationManager>& ui_weak_ptr, | 290 const base::WeakPtr<PushMessagingNotificationManager>& ui_weak_ptr, |
| 291 const GURL& origin, | 291 const GURL& origin, |
| 292 const PlatformNotificationData& notification_data, | 292 const PlatformNotificationData& notification_data, |
| 293 const base::Closure& message_handled_closure, | 293 const base::Closure& message_handled_closure, |
| 294 bool success, | 294 bool success, |
| 295 int64_t persistent_notification_id) { | 295 const std::string& notification_id) { |
| 296 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 296 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 297 BrowserThread::PostTask( | 297 BrowserThread::PostTask( |
| 298 BrowserThread::UI, FROM_HERE, | 298 BrowserThread::UI, FROM_HERE, |
| 299 base::Bind(&PushMessagingNotificationManager::DidWriteNotificationData, | 299 base::Bind(&PushMessagingNotificationManager::DidWriteNotificationData, |
| 300 ui_weak_ptr, origin, notification_data, | 300 ui_weak_ptr, origin, notification_data, |
| 301 message_handled_closure, success, persistent_notification_id)); | 301 message_handled_closure, success, notification_id)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void PushMessagingNotificationManager::DidWriteNotificationData( | 304 void PushMessagingNotificationManager::DidWriteNotificationData( |
| 305 const GURL& origin, | 305 const GURL& origin, |
| 306 const PlatformNotificationData& notification_data, | 306 const PlatformNotificationData& notification_data, |
| 307 const base::Closure& message_handled_closure, | 307 const base::Closure& message_handled_closure, |
| 308 bool success, | 308 bool success, |
| 309 int64_t persistent_notification_id) { | 309 const std::string& notification_id) { |
| 310 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 310 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 311 if (!success) { | 311 if (!success) { |
| 312 DLOG(ERROR) << "Writing forced notification to database should not fail"; | 312 DLOG(ERROR) << "Writing forced notification to database should not fail"; |
| 313 message_handled_closure.Run(); | 313 message_handled_closure.Run(); |
| 314 return; | 314 return; |
| 315 } | 315 } |
| 316 | 316 |
| 317 // Do not pass service worker scope. The origin will be used instead of the | 317 // Do not pass service worker scope. The origin will be used instead of the |
| 318 // service worker scope to determine whether a notification should be | 318 // service worker scope to determine whether a notification should be |
| 319 // attributed to a WebAPK on Android. This is OK because this code path is hit | 319 // attributed to a WebAPK on Android. This is OK because this code path is hit |
| 320 // rarely. | 320 // rarely. |
| 321 PlatformNotificationServiceImpl::GetInstance()->DisplayPersistentNotification( | 321 PlatformNotificationServiceImpl::GetInstance()->DisplayPersistentNotification( |
| 322 profile_, persistent_notification_id, GURL() /* service_worker_scope */, | 322 profile_, notification_id, GURL() /* service_worker_scope */, origin, |
| 323 origin, notification_data, NotificationResources()); | 323 notification_data, NotificationResources()); |
| 324 | 324 |
| 325 message_handled_closure.Run(); | 325 message_handled_closure.Run(); |
| 326 } | 326 } |
| OLD | NEW |