Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc

Issue 2083363002: Remove calls to deprecated MessageLoop methods in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
20 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "chrome/renderer/safe_browsing/features.h" 25 #include "chrome/renderer/safe_browsing/features.h"
25 #include "chrome/renderer/safe_browsing/mock_feature_extractor_clock.h" 26 #include "chrome/renderer/safe_browsing/mock_feature_extractor_clock.h"
26 #include "chrome/renderer/safe_browsing/murmurhash3_util.h" 27 #include "chrome/renderer/safe_browsing/murmurhash3_util.h"
27 #include "chrome/renderer/safe_browsing/test_utils.h" 28 #include "chrome/renderer/safe_browsing/test_utils.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool ExtractFeatures(const base::string16* page_text, 96 bool ExtractFeatures(const base::string16* page_text,
96 FeatureMap* features, 97 FeatureMap* features,
97 std::set<uint32_t>* shingle_hashes) { 98 std::set<uint32_t>* shingle_hashes) {
98 success_ = false; 99 success_ = false;
99 extractor_->ExtractFeatures( 100 extractor_->ExtractFeatures(
100 page_text, 101 page_text,
101 features, 102 features,
102 shingle_hashes, 103 shingle_hashes,
103 base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone, 104 base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone,
104 base::Unretained(this))); 105 base::Unretained(this)));
105 msg_loop_.Run(); 106 base::RunLoop().Run();
106 return success_; 107 return success_;
107 } 108 }
108 109
109 void PartialExtractFeatures(const base::string16* page_text, 110 void PartialExtractFeatures(const base::string16* page_text,
110 FeatureMap* features, 111 FeatureMap* features,
111 std::set<uint32_t>* shingle_hashes) { 112 std::set<uint32_t>* shingle_hashes) {
112 extractor_->ExtractFeatures( 113 extractor_->ExtractFeatures(
113 page_text, 114 page_text,
114 features, 115 features,
115 shingle_hashes, 116 shingle_hashes,
116 base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone, 117 base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone,
117 base::Unretained(this))); 118 base::Unretained(this)));
118 msg_loop_.task_runner()->PostTask( 119 msg_loop_.task_runner()->PostTask(
119 FROM_HERE, base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, 120 FROM_HERE, base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction,
120 base::Unretained(this))); 121 base::Unretained(this)));
121 msg_loop_.RunUntilIdle(); 122 base::RunLoop().RunUntilIdle();
122 } 123 }
123 124
124 // Completion callback for feature extraction. 125 // Completion callback for feature extraction.
125 void ExtractionDone(bool success) { 126 void ExtractionDone(bool success) {
126 success_ = success; 127 success_ = success;
127 msg_loop_.QuitWhenIdle(); 128 msg_loop_.QuitWhenIdle();
128 } 129 }
129 130
130 void QuitExtraction() { 131 void QuitExtraction() {
131 extractor_->CancelPendingExtraction(); 132 extractor_->CancelPendingExtraction();
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // Now extract normally and make sure nothing breaks. 460 // Now extract normally and make sure nothing breaks.
460 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features, &shingle_hashes)); 461 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features, &shingle_hashes));
461 462
462 FeatureMap expected_features; 463 FeatureMap expected_features;
463 expected_features.AddBooleanFeature(features::kPageTerm + 464 expected_features.AddBooleanFeature(features::kPageTerm +
464 std::string("multi word test")); 465 std::string("multi word test"));
465 ExpectFeatureMapsAreEqual(features, expected_features); 466 ExpectFeatureMapsAreEqual(features, expected_features);
466 } 467 }
467 468
468 } // namespace safe_browsing 469 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698