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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier.cc

Issue 2829163004: Remove uses of base::hash_map from //chrome (Closed)
Patch Set: Fixes Created 3 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer/safe_browsing/phishing_classifier.h" 5 #include "chrome/renderer/safe_browsing/phishing_classifier.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void PhishingClassifier::TermExtractionFinished(bool success) { 186 void PhishingClassifier::TermExtractionFinished(bool success) {
187 if (success) { 187 if (success) {
188 blink::WebLocalFrame* main_frame = render_frame_->GetWebFrame(); 188 blink::WebLocalFrame* main_frame = render_frame_->GetWebFrame();
189 189
190 // Hash all of the features so that they match the model, then compute 190 // Hash all of the features so that they match the model, then compute
191 // the score. 191 // the score.
192 FeatureMap hashed_features; 192 FeatureMap hashed_features;
193 ClientPhishingRequest verdict; 193 ClientPhishingRequest verdict;
194 verdict.set_model_version(scorer_->model_version()); 194 verdict.set_model_version(scorer_->model_version());
195 verdict.set_url(main_frame->GetDocument().Url().GetString().Utf8()); 195 verdict.set_url(main_frame->GetDocument().Url().GetString().Utf8());
196 for (base::hash_map<std::string, double>::const_iterator it = 196 for (const auto& it : features_->features()) {
197 features_->features().begin(); 197 DVLOG(2) << "Feature: " << it.first << " = " << it.second;
198 it != features_->features().end(); ++it) {
199 DVLOG(2) << "Feature: " << it->first << " = " << it->second;
200 bool result = hashed_features.AddRealFeature( 198 bool result = hashed_features.AddRealFeature(
201 crypto::SHA256HashString(it->first), it->second); 199 crypto::SHA256HashString(it.first), it.second);
202 DCHECK(result); 200 DCHECK(result);
203 ClientPhishingRequest::Feature* feature = verdict.add_feature_map(); 201 ClientPhishingRequest::Feature* feature = verdict.add_feature_map();
204 feature->set_name(it->first); 202 feature->set_name(it.first);
205 feature->set_value(it->second); 203 feature->set_value(it.second);
206 } 204 }
207 for (std::set<uint32_t>::const_iterator it = shingle_hashes_->begin(); 205 for (const auto& it : *shingle_hashes_) {
208 it != shingle_hashes_->end(); ++it) { 206 verdict.add_shingle_hashes(it);
209 verdict.add_shingle_hashes(*it);
210 } 207 }
211 float score = static_cast<float>(scorer_->ComputeScore(hashed_features)); 208 float score = static_cast<float>(scorer_->ComputeScore(hashed_features));
212 verdict.set_client_score(score); 209 verdict.set_client_score(score);
213 verdict.set_is_phishing(score >= kPhishyThreshold); 210 verdict.set_is_phishing(score >= kPhishyThreshold);
214 RunCallback(verdict); 211 RunCallback(verdict);
215 } else { 212 } else {
216 RunFailureCallback(); 213 RunFailureCallback();
217 } 214 }
218 } 215 }
219 216
(...skipping 22 matching lines...) Expand all
242 } 239 }
243 240
244 void PhishingClassifier::Clear() { 241 void PhishingClassifier::Clear() {
245 page_text_ = NULL; 242 page_text_ = NULL;
246 done_callback_.Reset(); 243 done_callback_.Reset();
247 features_.reset(NULL); 244 features_.reset(NULL);
248 shingle_hashes_.reset(NULL); 245 shingle_hashes_.reset(NULL);
249 } 246 }
250 247
251 } // namespace safe_browsing 248 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698