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

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

Issue 1057573002: Implement the ability to get all notifications in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-Integrate
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_impl.cc
diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
index ba23fc171971985d8e6bdee0d52f3e566ccc7015..ad98bdfd720407d65d6c22d30c5f54270fb0b17a 100644
--- a/content/browser/notifications/platform_notification_context_impl.cc
+++ b/content/browser/notifications/platform_notification_context_impl.cc
@@ -116,6 +116,57 @@ void PlatformNotificationContextImpl::DoReadNotificationData(
base::Bind(callback, false /* success */, NotificationDatabaseData()));
}
+void PlatformNotificationContextImpl::
+ ReadAllNotificationDataForServiceWorkerRegistration(
+ const GURL& origin,
+ int64_t service_worker_registration_id,
+ const ReadAllResultCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LazyInitialize(
+ base::Bind(&PlatformNotificationContextImpl::
+ DoReadAllNotificationDataForServiceWorkerRegistration,
+ this, origin, service_worker_registration_id, callback),
+ base::Bind(callback,
+ false /* success */,
+ std::vector<NotificationDatabaseData>()));
+}
+
+void PlatformNotificationContextImpl::
+ DoReadAllNotificationDataForServiceWorkerRegistration(
+ const GURL& origin,
+ int64_t service_worker_registration_id,
+ const ReadAllResultCallback& callback) {
+ DCHECK(task_runner_->RunsTasksOnCurrentThread());
+
+ std::vector<NotificationDatabaseData> notification_datas;
+
+ NotificationDatabase::Status status =
+ database_->ReadAllNotificationDataForServiceWorkerRegistration(
+ origin, service_worker_registration_id, &notification_datas);
+
+ // TODO(peter): Record UMA on |status| for reading from the database.
johnme 2015/04/08 18:12:41 Since you wrote this patch, the other methods now
Peter Beverloo 2015/04/14 18:01:27 Done.
+
+ if (status == NotificationDatabase::STATUS_OK) {
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(callback,
+ true /* success */,
+ notification_datas));
+ return;
+ }
+
+ // Blow away the database if reading data failed due to corruption.
+ if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
+ DestroyDatabase();
+
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(callback,
+ false /* success */,
+ std::vector<NotificationDatabaseData>()));
+}
+
void PlatformNotificationContextImpl::WriteNotificationData(
const GURL& origin,
const NotificationDatabaseData& database_data,

Powered by Google App Engine
This is Rietveld 408576698