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

Side by Side Diff: components/search_engines/util.cc

Issue 2404593002: Don't access owning pointers after they've relinquished ownership. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/search_engines/util.h" 5 #include "components/search_engines/util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 DCHECK(prepopulated_urls); 193 DCHECK(prepopulated_urls);
194 DCHECK(template_urls); 194 DCHECK(template_urls);
195 195
196 ActionsFromPrepopulateData actions(CreateActionsFromCurrentPrepopulateData( 196 ActionsFromPrepopulateData actions(CreateActionsFromCurrentPrepopulateData(
197 prepopulated_urls, *template_urls, default_search_provider)); 197 prepopulated_urls, *template_urls, default_search_provider));
198 198
199 // Remove items. 199 // Remove items.
200 for (const auto* removed_engine : actions.removed_engines) { 200 for (const auto* removed_engine : actions.removed_engines) {
201 auto j = FindTemplateURL(template_urls, removed_engine); 201 auto j = FindTemplateURL(template_urls, removed_engine);
202 DCHECK(j != template_urls->end()); 202 DCHECK(j != template_urls->end());
203 std::unique_ptr<TemplateURL> template_url = std::move(*j);
204 DCHECK(!default_search_provider || 203 DCHECK(!default_search_provider ||
205 (*j)->prepopulate_id() != default_search_provider->prepopulate_id()); 204 (*j)->prepopulate_id() != default_search_provider->prepopulate_id());
205 std::unique_ptr<TemplateURL> template_url = std::move(*j);
206 template_urls->erase(j); 206 template_urls->erase(j);
207 if (service) { 207 if (service) {
208 service->RemoveKeyword(template_url->id()); 208 service->RemoveKeyword(template_url->id());
209 if (removed_keyword_guids) 209 if (removed_keyword_guids)
210 removed_keyword_guids->insert(template_url->sync_guid()); 210 removed_keyword_guids->insert(template_url->sync_guid());
211 } 211 }
212 } 212 }
213 213
214 // Edit items. 214 // Edit items.
215 for (const auto& edited_engine : actions.edited_engines) { 215 for (const auto& edited_engine : actions.edited_engines) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 TemplateURLService::OwnedTemplateURLVector::iterator FindTemplateURL( 371 TemplateURLService::OwnedTemplateURLVector::iterator FindTemplateURL(
372 TemplateURLService::OwnedTemplateURLVector* urls, 372 TemplateURLService::OwnedTemplateURLVector* urls,
373 const TemplateURL* url) { 373 const TemplateURL* url) {
374 return std::find_if(urls->begin(), urls->end(), 374 return std::find_if(urls->begin(), urls->end(),
375 [url](const std::unique_ptr<TemplateURL>& ptr) { 375 [url](const std::unique_ptr<TemplateURL>& ptr) {
376 return ptr.get() == url; 376 return ptr.get() == url;
377 }); 377 });
378 } 378 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698