Chromium Code Reviews| Index: content/browser/notifications/platform_notification_context_impl.cc |
| diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc |
| index c7a6b2c575c95c23a826e0fb529544e236eb8d89..b2b372fadc86a15294efc4bb012e3bd7ceef2c06 100644 |
| --- a/content/browser/notifications/platform_notification_context_impl.cc |
| +++ b/content/browser/notifications/platform_notification_context_impl.cc |
| @@ -252,10 +252,10 @@ void PlatformNotificationContextImpl:: |
| UMA_HISTOGRAM_ENUMERATION("Notifications.Database.ReadForServiceWorkerResult", |
| status, NotificationDatabase::STATUS_COUNT); |
| + std::vector<std::string> obsolete_notifications; |
| + |
| if (status == NotificationDatabase::STATUS_OK) { |
| if (synchronization_supported) { |
| - // Filter out notifications that are not actually on display anymore. |
| - // TODO(miguelg) synchronize the database if there are inconsistencies. |
| for (auto it = notification_datas.begin(); |
| it != notification_datas.end();) { |
| // The database is only used for persistent notifications. |
| @@ -264,6 +264,7 @@ void PlatformNotificationContextImpl:: |
| if (displayed_notifications->count(it->notification_id)) { |
| ++it; |
| } else { |
| + obsolete_notifications.push_back(it->notification_id); |
| it = notification_datas.erase(it); |
| } |
| } |
| @@ -272,6 +273,10 @@ void PlatformNotificationContextImpl:: |
| BrowserThread::PostTask( |
| BrowserThread::IO, FROM_HERE, |
| base::Bind(callback, true /* success */, notification_datas)); |
| + |
| + // Remove notifications that are not actually on display anymore. |
| + for (const auto& it : obsolete_notifications) |
| + database_->DeleteNotificationData(it, origin); |
|
Peter Beverloo
2017/02/03 18:57:56
This won't actually work (and would need a test) -
|
| return; |
| } |