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

Unified Diff: content/browser/notifications/platform_notification_context_impl.cc

Issue 2671603005: Fix a couple of TODOs (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/notifications/notification_database.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « content/browser/notifications/notification_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698