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/renderer/safe_browsing/phishing_term_feature_extractor.h" | 5 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::Unretained(this))); | 114 base::Unretained(this))); |
115 msg_loop_.task_runner()->PostTask( | 115 msg_loop_.task_runner()->PostTask( |
116 FROM_HERE, base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, | 116 FROM_HERE, base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, |
117 base::Unretained(this))); | 117 base::Unretained(this))); |
118 msg_loop_.RunUntilIdle(); | 118 msg_loop_.RunUntilIdle(); |
119 } | 119 } |
120 | 120 |
121 // Completion callback for feature extraction. | 121 // Completion callback for feature extraction. |
122 void ExtractionDone(bool success) { | 122 void ExtractionDone(bool success) { |
123 success_ = success; | 123 success_ = success; |
124 msg_loop_.Quit(); | 124 msg_loop_.QuitWhenIdle(); |
125 } | 125 } |
126 | 126 |
127 void QuitExtraction() { | 127 void QuitExtraction() { |
128 extractor_->CancelPendingExtraction(); | 128 extractor_->CancelPendingExtraction(); |
129 msg_loop_.Quit(); | 129 msg_loop_.QuitWhenIdle(); |
130 } | 130 } |
131 | 131 |
132 base::MessageLoop msg_loop_; | 132 base::MessageLoop msg_loop_; |
133 MockFeatureExtractorClock clock_; | 133 MockFeatureExtractorClock clock_; |
134 scoped_ptr<PhishingTermFeatureExtractor> extractor_; | 134 scoped_ptr<PhishingTermFeatureExtractor> extractor_; |
135 base::hash_set<std::string> term_hashes_; | 135 base::hash_set<std::string> term_hashes_; |
136 base::hash_set<uint32> word_hashes_; | 136 base::hash_set<uint32> word_hashes_; |
137 bool success_; // holds the success value from ExtractFeatures | 137 bool success_; // holds the success value from ExtractFeatures |
138 }; | 138 }; |
139 | 139 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 // Now extract normally and make sure nothing breaks. | 456 // Now extract normally and make sure nothing breaks. |
457 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features, &shingle_hashes)); | 457 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features, &shingle_hashes)); |
458 | 458 |
459 FeatureMap expected_features; | 459 FeatureMap expected_features; |
460 expected_features.AddBooleanFeature(features::kPageTerm + | 460 expected_features.AddBooleanFeature(features::kPageTerm + |
461 std::string("multi word test")); | 461 std::string("multi word test")); |
462 ExpectFeatureMapsAreEqual(features, expected_features); | 462 ExpectFeatureMapsAreEqual(features, expected_features); |
463 } | 463 } |
464 | 464 |
465 } // namespace safe_browsing | 465 } // namespace safe_browsing |
OLD | NEW |