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, ¬ification_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, |