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

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

Issue 2739943006: Do not delete notification ids unknown by the display service (Closed)
Patch Set: keep conent/test/* files Created 3 years, 9 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 b2b372fadc86a15294efc4bb012e3bd7ceef2c06..c7a6b2c575c95c23a826e0fb529544e236eb8d89 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,7 +264,6 @@ void PlatformNotificationContextImpl::
if (displayed_notifications->count(it->notification_id)) {
++it;
} else {
- obsolete_notifications.push_back(it->notification_id);
it = notification_datas.erase(it);
}
}
@@ -273,10 +272,6 @@ 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