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

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

Issue 2565323004: [NOT FOR COMMIT] Ownership clean-up for 2534443002 (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « content/browser/notifications/platform_notification_context_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&notification_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(&notification_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);
« no previous file with comments | « content/browser/notifications/platform_notification_context_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698