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

Side by Side Diff: components/dom_distiller/core/page_features.cc

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 "components/dom_distiller/core/page_features.h" 5 #include "components/dom_distiller/core/page_features.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
10 11
11 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "third_party/re2/src/re2/re2.h" 13 #include "third_party/re2/src/re2/re2.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace dom_distiller { 16 namespace dom_distiller {
17 /* This code needs to derive features in the same way and order in which they 17 /* This code needs to derive features in the same way and order in which they
18 * are derived when training the model. Parts of that code are reproduced in the 18 * are derived when training the model. Parts of that code are reproduced in the
19 * comments below. 19 * comments below.
20 */ 20 */
21 21
22 namespace { 22 namespace {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return features; 145 return features;
146 } 146 }
147 147
148 std::vector<double> CalculateDerivedFeaturesFromJSON( 148 std::vector<double> CalculateDerivedFeaturesFromJSON(
149 const base::Value* stringified_json) { 149 const base::Value* stringified_json) {
150 std::string stringified; 150 std::string stringified;
151 if (!stringified_json->GetAsString(&stringified)) { 151 if (!stringified_json->GetAsString(&stringified)) {
152 return std::vector<double>(); 152 return std::vector<double>();
153 } 153 }
154 154
155 scoped_ptr<base::Value> json = base::JSONReader::Read(stringified); 155 std::unique_ptr<base::Value> json = base::JSONReader::Read(stringified);
156 if (!json) { 156 if (!json) {
157 return std::vector<double>(); 157 return std::vector<double>();
158 } 158 }
159 159
160 const base::DictionaryValue* dict; 160 const base::DictionaryValue* dict;
161 if (!json->GetAsDictionary(&dict)) { 161 if (!json->GetAsDictionary(&dict)) {
162 return std::vector<double>(); 162 return std::vector<double>();
163 } 163 }
164 164
165 bool isOGArticle = false; 165 bool isOGArticle = false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 features.push_back(mozScore); 241 features.push_back(mozScore);
242 // 'mozScoreAllSqrt' 242 // 'mozScoreAllSqrt'
243 features.push_back(mozScoreAllSqrt); 243 features.push_back(mozScoreAllSqrt);
244 // 'mozScoreAllLinear' 244 // 'mozScoreAllLinear'
245 features.push_back(mozScoreAllLinear); 245 features.push_back(mozScoreAllLinear);
246 246
247 return features; 247 return features;
248 } 248 }
249 249
250 } // namespace dom_distiller 250 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/fake_distiller_page.h ('k') | components/dom_distiller/core/page_features_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698