| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 int num_pending_; // Number of pending feature extractions. | 205 int num_pending_; // Number of pending feature extractions. |
| 206 scoped_ptr<BrowserFeatureExtractor> extractor_; | 206 scoped_ptr<BrowserFeatureExtractor> extractor_; |
| 207 std::map<void*, bool> success_; | 207 std::map<void*, bool> success_; |
| 208 scoped_ptr<BrowseInfo> browse_info_; | 208 scoped_ptr<BrowseInfo> browse_info_; |
| 209 scoped_ptr<StrictMock<MockClientSideDetectionHost> > host_; | 209 scoped_ptr<StrictMock<MockClientSideDetectionHost> > host_; |
| 210 scoped_refptr<StrictMock<MockSafeBrowsingDatabaseManager> > db_manager_; | 210 scoped_refptr<StrictMock<MockSafeBrowsingDatabaseManager> > db_manager_; |
| 211 | 211 |
| 212 private: | 212 private: |
| 213 void ExtractFeaturesDone(bool success, | 213 void ExtractFeaturesDone(bool success, ClientPhishingRequest* request) { |
| 214 scoped_ptr<ClientPhishingRequest> request) { | 214 ASSERT_EQ(0U, success_.count(request)); |
| 215 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 215 success_[request] = success; |
| 216 ASSERT_EQ(0U, success_.count(request.get())); | |
| 217 // The pointer doesn't really belong to us. It belongs to | |
| 218 // the test case which passed it to ExtractFeatures above. | |
| 219 success_[request.release()] = success; | |
| 220 if (--num_pending_ == 0) { | 216 if (--num_pending_ == 0) { |
| 221 base::MessageLoop::current()->Quit(); | 217 base::MessageLoop::current()->Quit(); |
| 222 } | 218 } |
| 223 } | 219 } |
| 224 | 220 |
| 225 void ExtractMalwareFeaturesDone( | 221 void ExtractMalwareFeaturesDone( |
| 226 bool success, | 222 bool success, |
| 227 scoped_ptr<ClientMalwareRequest> request) { | 223 scoped_ptr<ClientMalwareRequest> request) { |
| 228 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 224 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 229 ASSERT_EQ(0U, success_.count(request.get())); | 225 ASSERT_EQ(0U, success_.count(request.get())); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // First ip is good but all the others are bad. | 645 // First ip is good but all the others are bad. |
| 650 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); | 646 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); |
| 651 } | 647 } |
| 652 | 648 |
| 653 ExtractMalwareFeatures(&request); | 649 ExtractMalwareFeatures(&request); |
| 654 // The number of IP matched url we store is capped at 5 IPs per request. | 650 // The number of IP matched url we store is capped at 5 IPs per request. |
| 655 EXPECT_EQ(5, request.bad_ip_url_info_size()); | 651 EXPECT_EQ(5, request.bad_ip_url_info_size()); |
| 656 } | 652 } |
| 657 | 653 |
| 658 } // namespace safe_browsing | 654 } // namespace safe_browsing |
| OLD | NEW |