| OLD | NEW |
| 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/browser/safe_browsing/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 EXPECT_EQ(1U, success_.count(request)); | 113 EXPECT_EQ(1U, success_.count(request)); |
| 114 return success_.count(request) ? success_[request] : false; | 114 return success_.count(request) ? success_[request] : false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void StartExtractFeatures(ClientPhishingRequest* request) { | 117 void StartExtractFeatures(ClientPhishingRequest* request) { |
| 118 success_.erase(request); | 118 success_.erase(request); |
| 119 ++num_pending_; | 119 ++num_pending_; |
| 120 extractor_->ExtractFeatures( | 120 extractor_->ExtractFeatures( |
| 121 browse_info_.get(), | 121 browse_info_.get(), |
| 122 request, | 122 request, |
| 123 NewCallback(this, | 123 base::Bind(&BrowserFeatureExtractorTest::ExtractFeaturesDone, |
| 124 &BrowserFeatureExtractorTest::ExtractFeaturesDone)); | 124 base::Unretained(this))); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void GetFeatureMap(const ClientPhishingRequest& request, | 127 void GetFeatureMap(const ClientPhishingRequest& request, |
| 128 std::map<std::string, double>* features) { | 128 std::map<std::string, double>* features) { |
| 129 for (int i = 0; i < request.non_model_feature_map_size(); ++i) { | 129 for (int i = 0; i < request.non_model_feature_map_size(); ++i) { |
| 130 const ClientPhishingRequest::Feature& feature = | 130 const ClientPhishingRequest::Feature& feature = |
| 131 request.non_model_feature_map(i); | 131 request.non_model_feature_map(i); |
| 132 EXPECT_EQ(0U, features->count(feature.name())); | 132 EXPECT_EQ(0U, features->count(feature.name())); |
| 133 (*features)[feature.name()] = feature.value(); | 133 (*features)[feature.name()] = feature.value(); |
| 134 } | 134 } |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 EXPECT_TRUE(features.count(StringPrintf("%s%s", | 496 EXPECT_TRUE(features.count(StringPrintf("%s%s", |
| 497 features::kSafeBrowsingMaliciousUrl, | 497 features::kSafeBrowsingMaliciousUrl, |
| 498 "http://www.malware.com/"))); | 498 "http://www.malware.com/"))); |
| 499 EXPECT_TRUE(features.count(StringPrintf("%s%s", | 499 EXPECT_TRUE(features.count(StringPrintf("%s%s", |
| 500 features::kSafeBrowsingOriginalUrl, | 500 features::kSafeBrowsingOriginalUrl, |
| 501 "http://www.good.com/"))); | 501 "http://www.good.com/"))); |
| 502 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]); | 502 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]); |
| 503 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]); | 503 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]); |
| 504 } | 504 } |
| 505 } // namespace safe_browsing | 505 } // namespace safe_browsing |
| OLD | NEW |