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

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

Issue 2868793003: RE-add the ability to delete notification ids unknown by the display service. (Closed)
Patch Set: Created 3 years, 7 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
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 8ef474c619dccc40b4cef826bda96630b8e02806..8a15289d8aac51406bc6db6714058e99d5dc3317 100644
--- a/content/browser/notifications/platform_notification_context_impl.cc
+++ b/content/browser/notifications/platform_notification_context_impl.cc
@@ -281,10 +281,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 (supports_synchronization) {
- // 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.
@@ -293,6 +293,7 @@ void PlatformNotificationContextImpl::
if (displayed_notifications->count(it->notification_id)) {
++it;
} else {
+ obsolete_notifications.push_back(it->notification_id);
it = notification_datas.erase(it);
}
}
@@ -301,6 +302,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);
return;
}

Powered by Google App Engine
This is Rietveld 408576698