| 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, ClientPhishingRequest* request) { | 213 void ExtractFeaturesDone(bool success, |
| 214 ASSERT_EQ(0U, success_.count(request)); | 214 scoped_ptr<ClientPhishingRequest> request) { |
| 215 success_[request] = success; | 215 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 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; |
| 216 if (--num_pending_ == 0) { | 220 if (--num_pending_ == 0) { |
| 217 base::MessageLoop::current()->Quit(); | 221 base::MessageLoop::current()->Quit(); |
| 218 } | 222 } |
| 219 } | 223 } |
| 220 | 224 |
| 221 void ExtractMalwareFeaturesDone( | 225 void ExtractMalwareFeaturesDone( |
| 222 bool success, | 226 bool success, |
| 223 scoped_ptr<ClientMalwareRequest> request) { | 227 scoped_ptr<ClientMalwareRequest> request) { |
| 224 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 228 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 225 ASSERT_EQ(0U, success_.count(request.get())); | 229 ASSERT_EQ(0U, success_.count(request.get())); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 // First ip is good but all the others are bad. | 649 // First ip is good but all the others are bad. |
| 646 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); | 650 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); |
| 647 } | 651 } |
| 648 | 652 |
| 649 ExtractMalwareFeatures(&request); | 653 ExtractMalwareFeatures(&request); |
| 650 // The number of IP matched url we store is capped at 5 IPs per request. | 654 // The number of IP matched url we store is capped at 5 IPs per request. |
| 651 EXPECT_EQ(5, request.bad_ip_url_info_size()); | 655 EXPECT_EQ(5, request.bad_ip_url_info_size()); |
| 652 } | 656 } |
| 653 | 657 |
| 654 } // namespace safe_browsing | 658 } // namespace safe_browsing |
| OLD | NEW |