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

Side by Side Diff: chrome/browser/interests/interests_fetcher.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 7 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/interests/interests_fetcher.h" 5 #include "chrome/browser/interests/interests_fetcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return nullptr; 175 return nullptr;
176 } 176 }
177 177
178 const base::ListValue* interests_list = nullptr; 178 const base::ListValue* interests_list = nullptr;
179 if (!dict->GetList(kIdInterests, &interests_list)) { 179 if (!dict->GetList(kIdInterests, &interests_list)) {
180 DLOG(WARNING) << "Failed to parse interests list."; 180 DLOG(WARNING) << "Failed to parse interests list.";
181 return nullptr; 181 return nullptr;
182 } 182 }
183 183
184 std::unique_ptr<std::vector<Interest>> res(new std::vector<Interest>()); 184 std::unique_ptr<std::vector<Interest>> res(new std::vector<Interest>());
185 for (const base::Value* entry : *interests_list) { 185 for (const auto& entry : *interests_list) {
186 const base::DictionaryValue* interest_dict = nullptr; 186 const base::DictionaryValue* interest_dict = nullptr;
187 if (!entry->GetAsDictionary(&interest_dict)) { 187 if (!entry->GetAsDictionary(&interest_dict)) {
188 DLOG(WARNING) << "Failed to parse interest dictionary."; 188 DLOG(WARNING) << "Failed to parse interest dictionary.";
189 continue; 189 continue;
190 } 190 }
191 191
192 // Extract the parts of the interest. 192 // Extract the parts of the interest.
193 std::string name; 193 std::string name;
194 std::string image_url; 194 std::string image_url;
195 double relevance = 0; 195 double relevance = 0;
(...skipping 11 matching lines...) Expand all
207 if (!interest_dict->GetDouble(kIdInterestRelevance, &relevance)) { 207 if (!interest_dict->GetDouble(kIdInterestRelevance, &relevance)) {
208 DLOG(WARNING) << "Failed to parse interest relevance."; 208 DLOG(WARNING) << "Failed to parse interest relevance.";
209 continue; 209 continue;
210 } 210 }
211 211
212 res->push_back(Interest{name, GURL(image_url), relevance}); 212 res->push_back(Interest{name, GURL(image_url), relevance});
213 } 213 }
214 214
215 return res; 215 return res;
216 } 216 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.cc ('k') | chrome/browser/metrics/plugin_metrics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698