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

Side by Side Diff: chrome/browser/notifications/notifier_state_tracker.cc

Issue 2336863003: Change more base::ListValue methods to use std::unique_ptr. (Closed)
Patch Set: . Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/notifier_state_tracker.h" 5 #include "chrome/browser/notifications/notifier_state_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 #endif 137 #endif
138 break; 138 break;
139 default: 139 default:
140 NOTREACHED(); 140 NOTREACHED();
141 } 141 }
142 DCHECK(pref_name != NULL); 142 DCHECK(pref_name != NULL);
143 143
144 ListPrefUpdate update(profile_->GetPrefs(), pref_name); 144 ListPrefUpdate update(profile_->GetPrefs(), pref_name);
145 base::ListValue* const list = update.Get(); 145 base::ListValue* const list = update.Get();
146 if (add_new_item) { 146 if (add_new_item) {
147 // AppendIfNotPresent will delete |adding_value| when the same value 147 list->AppendIfNotPresent(std::move(id));
148 // already exists.
149 list->AppendIfNotPresent(id.release());
150 } else { 148 } else {
151 list->Remove(*id, NULL); 149 list->Remove(*id, nullptr);
152 } 150 }
153 } 151 }
154 152
155 void NotifierStateTracker::OnStringListPrefChanged( 153 void NotifierStateTracker::OnStringListPrefChanged(
156 const char* pref_name, std::set<std::string>* ids_field) { 154 const char* pref_name, std::set<std::string>* ids_field) {
157 ids_field->clear(); 155 ids_field->clear();
158 // Separate GetPrefs()->GetList() to analyze the crash. See crbug.com/322320 156 // Separate GetPrefs()->GetList() to analyze the crash. See crbug.com/322320
159 const PrefService* pref_service = profile_->GetPrefs(); 157 const PrefService* pref_service = profile_->GetPrefs();
160 CHECK(pref_service); 158 CHECK(pref_service);
161 const base::ListValue* pref_list = pref_service->GetList(pref_name); 159 const base::ListValue* pref_list = pref_service->GetList(pref_name);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Tell the IO thread that this extension's permission for notifications 196 // Tell the IO thread that this extension's permission for notifications
199 // has changed. 197 // has changed.
200 extensions::InfoMap* extension_info_map = 198 extensions::InfoMap* extension_info_map =
201 extensions::ExtensionSystem::Get(profile_)->info_map(); 199 extensions::ExtensionSystem::Get(profile_)->info_map();
202 content::BrowserThread::PostTask( 200 content::BrowserThread::PostTask(
203 content::BrowserThread::IO, FROM_HERE, 201 content::BrowserThread::IO, FROM_HERE,
204 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 202 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
205 extension_info_map, notifier_id.id, !enabled)); 203 extension_info_map, notifier_id.id, !enabled));
206 } 204 }
207 #endif 205 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.cc ('k') | chrome/browser/permissions/chooser_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698