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

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 cc82d3395f4b6e4f6359ee09f1d772a5d5fc72c8..ff5f4f8e5f0a8be9d9052429d0566e561377e439 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;
+
+ // 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