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

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

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

Powered by Google App Engine
This is Rietveld 408576698