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

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

Issue 1008003003: Teach the PlatformNotificationContext how to delete notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-PlatformNotificationContext
Patch Set: Created 5 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.cc
diff --git a/content/browser/notifications/platform_notification_context.cc b/content/browser/notifications/platform_notification_context.cc
index 242f38994fb67fef1b2336f4297e4a83b3aa8c03..1245b61ca7d4b1d6cfa3b88c8f266e4b12b8383f 100644
--- a/content/browser/notifications/platform_notification_context.cc
+++ b/content/browser/notifications/platform_notification_context.cc
@@ -114,6 +114,36 @@ void PlatformNotificationContext::DoWriteNotificationData(
base::Bind(callback, false /* success */, 0 /* notification_id */));
}
+void PlatformNotificationContext::DeleteNotificationData(
+ int64_t notification_id,
+ const GURL& origin,
+ const DeleteResultCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LazyInitialize(
+ base::Bind(&PlatformNotificationContext::DoDeleteNotificationData,
+ this, notification_id, origin, callback),
+ base::Bind(callback, false /* success */));
+}
+
+void PlatformNotificationContext::DoDeleteNotificationData(
+ int64_t notification_id,
+ const GURL& origin,
+ const DeleteResultCallback& callback) {
+ DCHECK(task_runner_->RunsTasksOnCurrentThread());
+
+ NotificationDatabase::Status status =
+ database_->DeleteNotificationData(notification_id, origin);
+
+ const bool success = status == NotificationDatabase::STATUS_OK;
johnme 2015/03/16 16:55:18 It doesn't seem ideal to treat STATUS_ERROR_NOT_FO
johnme 2015/03/16 16:55:18 It doesn't seem ideal to treat STATUS_ERROR_NOT_FO
Peter Beverloo 2015/03/16 18:16:51 This is not the case anymore per new semantics in
+
+ // TODO(peter): Record UMA on |status| for reading from the database.
+ // TODO(peter): Do the DeleteAndStartOver dance for STATUS_ERROR_CORRUPTED.
+
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(callback, success));
+}
+
void PlatformNotificationContext::LazyInitialize(
const base::Closure& success_closure,
const base::Closure& failure_closure) {

Powered by Google App Engine
This is Rietveld 408576698