| 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 dbc39b5277f00b6cdeca2c1d096e9c312068a3b3..12d774f19bc7b167afde5ea3d3265d5b4ebe9c21 100644
|
| --- a/content/browser/notifications/platform_notification_context_impl.cc
|
| +++ b/content/browser/notifications/platform_notification_context_impl.cc
|
| @@ -186,14 +186,14 @@ void PlatformNotificationContextImpl::
|
| const GURL& origin,
|
| int64_t service_worker_registration_id,
|
| const ReadAllResultCallback& callback,
|
| - std::set<std::string>* notification_ids,
|
| + std::unique_ptr<std::set<std::string>> notification_ids,
|
| bool sync_supported) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| LazyInitialize(
|
| base::Bind(&PlatformNotificationContextImpl::
|
| DoReadAllNotificationDataForServiceWorkerRegistration,
|
| this, origin, service_worker_registration_id, callback,
|
| - base::Unretained(notification_ids), sync_supported),
|
| + base::Passed(¬ification_ids), sync_supported),
|
| base::Bind(callback, false /* success */,
|
| std::vector<NotificationDatabaseData>()));
|
| }
|
| @@ -205,30 +205,32 @@ void PlatformNotificationContextImpl::
|
| const ReadAllResultCallback& callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| - // notification_ids becomes owned by
|
| - // DoReadAllNotificationDataForServiceWorkerRegistration
|
| - std::set<std::string>* notification_ids = new std::set<std::string>();
|
| + std::unique_ptr<std::set<std::string>> notification_ids =
|
| + base::MakeUnique<std::set<std::string>>();
|
| +
|
| PlatformNotificationService* service =
|
| GetContentClient()->browser()->GetPlatformNotificationService();
|
|
|
| if (!service) {
|
| // Rely on the database only
|
| SynchronizeDisplayedNotificationsForServiceWorkerRegistration(
|
| - origin, service_worker_registration_id, callback, notification_ids,
|
| - false /* sync_supported */);
|
| + origin, service_worker_registration_id, callback,
|
| + std::move(notification_ids), false /* sync_supported */);
|
| return;
|
| }
|
|
|
| + std::set<std::string>* notification_ids_ptr = notification_ids.get();
|
| +
|
| BrowserThread::PostTaskAndReplyWithResult(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&PlatformNotificationService::GetDisplayedNotifications,
|
| base::Unretained(service), browser_context_,
|
| - base::Unretained(notification_ids)),
|
| + notification_ids_ptr),
|
| base::Bind(
|
| &PlatformNotificationContextImpl::
|
| SynchronizeDisplayedNotificationsForServiceWorkerRegistration,
|
| this, origin, service_worker_registration_id, callback,
|
| - base::Unretained(notification_ids)));
|
| + base::Passed(¬ification_ids)));
|
| }
|
|
|
| void PlatformNotificationContextImpl::
|
| @@ -236,11 +238,10 @@ void PlatformNotificationContextImpl::
|
| const GURL& origin,
|
| int64_t service_worker_registration_id,
|
| const ReadAllResultCallback& callback,
|
| - std::set<std::string>* displayed_notifications,
|
| + std::unique_ptr<std::set<std::string>> displayed_notifications,
|
| bool synchronization_supported) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| - std::unique_ptr<std::set<std::string>> displayed_ids =
|
| - base::WrapUnique(displayed_notifications);
|
| + DCHECK(displayed_notifications);
|
|
|
| std::vector<NotificationDatabaseData> notification_datas;
|
|
|
| @@ -253,14 +254,13 @@ void PlatformNotificationContextImpl::
|
|
|
| if (status == NotificationDatabase::STATUS_OK) {
|
| if (synchronization_supported) {
|
| - DCHECK(displayed_ids);
|
| // 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();) {
|
| if (NotificationIdGenerator::IsPersistentNotification(
|
| it->notification_id) &&
|
| - displayed_ids->count(it->notification_id)) {
|
| + displayed_notifications->count(it->notification_id)) {
|
| ++it;
|
| } else {
|
| it = notification_datas.erase(it);
|
|
|