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

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

Issue 2290503003: Remove use of stl_util in search_engines. (Closed)
Patch Set: ios for reals 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 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/search_host_to_urls_map.h" 5 #include "components/search_engines/search_host_to_urls_map.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "components/search_engines/template_url.h" 9 #include "components/search_engines/template_url.h"
10 10
11 SearchHostToURLsMap::SearchHostToURLsMap() 11 SearchHostToURLsMap::SearchHostToURLsMap()
12 : initialized_(false) { 12 : initialized_(false) {
13 } 13 }
14 14
15 SearchHostToURLsMap::~SearchHostToURLsMap() { 15 SearchHostToURLsMap::~SearchHostToURLsMap() {
16 } 16 }
17 17
18 void SearchHostToURLsMap::Init( 18 void SearchHostToURLsMap::Init(
19 const TemplateURLService::TemplateURLVector& template_urls, 19 const TemplateURLService::OwnedTemplateURLVector& template_urls,
20 const SearchTermsData& search_terms_data) { 20 const SearchTermsData& search_terms_data) {
21 DCHECK(!initialized_); 21 DCHECK(!initialized_);
22 initialized_ = true; // Set here so Add doesn't assert. 22 initialized_ = true; // Set here so Add doesn't assert.
23 Add(template_urls, search_terms_data); 23 Add(template_urls, search_terms_data);
24 } 24 }
25 25
26 void SearchHostToURLsMap::Add(TemplateURL* template_url, 26 void SearchHostToURLsMap::Add(TemplateURL* template_url,
27 const SearchTermsData& search_terms_data) { 27 const SearchTermsData& search_terms_data) {
28 DCHECK(initialized_); 28 DCHECK(initialized_);
29 DCHECK(template_url); 29 DCHECK(template_url);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const std::string& host) { 69 const std::string& host) {
70 DCHECK(initialized_); 70 DCHECK(initialized_);
71 71
72 HostToURLsMap::iterator urls_for_host = host_to_urls_map_.find(host); 72 HostToURLsMap::iterator urls_for_host = host_to_urls_map_.find(host);
73 if (urls_for_host == host_to_urls_map_.end() || urls_for_host->second.empty()) 73 if (urls_for_host == host_to_urls_map_.end() || urls_for_host->second.empty())
74 return NULL; 74 return NULL;
75 return &urls_for_host->second; 75 return &urls_for_host->second;
76 } 76 }
77 77
78 void SearchHostToURLsMap::Add( 78 void SearchHostToURLsMap::Add(
79 const TemplateURLService::TemplateURLVector& template_urls, 79 const TemplateURLService::OwnedTemplateURLVector& template_urls,
80 const SearchTermsData& search_terms_data) { 80 const SearchTermsData& search_terms_data) {
81 for (TemplateURLService::TemplateURLVector::const_iterator i( 81 for (auto& turl : template_urls)
Peter Kasting 2016/08/31 04:12:56 Nit: Seems like this could be const auto&.
82 template_urls.begin()); i != template_urls.end(); ++i) 82 Add(turl.get(), search_terms_data);
83 Add(*i, search_terms_data);
84 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698