| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 request.non_model_feature_map(i); | 172 request.non_model_feature_map(i); |
| 173 EXPECT_EQ(0U, features->count(feature.name())); | 173 EXPECT_EQ(0U, features->count(feature.name())); |
| 174 (*features)[feature.name()] = feature.value(); | 174 (*features)[feature.name()] = feature.value(); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void ExtractMalwareFeatures(ClientMalwareRequest* request) { | 178 void ExtractMalwareFeatures(ClientMalwareRequest* request) { |
| 179 // Feature extraction takes ownership of the request object | 179 // Feature extraction takes ownership of the request object |
| 180 // and passes it along to the done callback in the end. | 180 // and passes it along to the done callback in the end. |
| 181 StartExtractMalwareFeatures(request); | 181 StartExtractMalwareFeatures(request); |
| 182 base::MessageLoopForUI::current()->Run(); | 182 ASSERT_TRUE(base::MessageLoopForUI::IsCurrent()); |
| 183 base::RunLoop().Run(); |
| 183 EXPECT_EQ(1U, success_.count(request)); | 184 EXPECT_EQ(1U, success_.count(request)); |
| 184 EXPECT_TRUE(success_[request]); | 185 EXPECT_TRUE(success_[request]); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void StartExtractMalwareFeatures(ClientMalwareRequest* request) { | 188 void StartExtractMalwareFeatures(ClientMalwareRequest* request) { |
| 188 success_.erase(request); | 189 success_.erase(request); |
| 189 ++num_pending_; | 190 ++num_pending_; |
| 190 // We temporarily give up ownership of request to ExtractMalwareFeatures | 191 // We temporarily give up ownership of request to ExtractMalwareFeatures |
| 191 // but we'll regain ownership of it in ExtractMalwareFeaturesDone. | 192 // but we'll regain ownership of it in ExtractMalwareFeaturesDone. |
| 192 extractor_->ExtractMalwareFeatures( | 193 extractor_->ExtractMalwareFeatures( |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // First ip is good but all the others are bad. | 654 // First ip is good but all the others are bad. |
| 654 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); | 655 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); |
| 655 } | 656 } |
| 656 | 657 |
| 657 ExtractMalwareFeatures(&request); | 658 ExtractMalwareFeatures(&request); |
| 658 // The number of IP matched url we store is capped at 5 IPs per request. | 659 // The number of IP matched url we store is capped at 5 IPs per request. |
| 659 EXPECT_EQ(5, request.bad_ip_url_info_size()); | 660 EXPECT_EQ(5, request.bad_ip_url_info_size()); |
| 660 } | 661 } |
| 661 | 662 |
| 662 } // namespace safe_browsing | 663 } // namespace safe_browsing |
| OLD | NEW |