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

Side by Side Diff: chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc

Issue 1395103003: Don't use base::MessageLoop::{Quit,QuitClosure} in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 private: 214 private:
215 void ExtractFeaturesDone(bool success, 215 void ExtractFeaturesDone(bool success,
216 scoped_ptr<ClientPhishingRequest> request) { 216 scoped_ptr<ClientPhishingRequest> request) {
217 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 217 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 ASSERT_EQ(0U, success_.count(request.get())); 218 ASSERT_EQ(0U, success_.count(request.get()));
219 // The pointer doesn't really belong to us. It belongs to 219 // The pointer doesn't really belong to us. It belongs to
220 // the test case which passed it to ExtractFeatures above. 220 // the test case which passed it to ExtractFeatures above.
221 success_[request.release()] = success; 221 success_[request.release()] = success;
222 if (--num_pending_ == 0) { 222 if (--num_pending_ == 0) {
223 base::MessageLoop::current()->Quit(); 223 base::MessageLoop::current()->QuitWhenIdle();
224 } 224 }
225 } 225 }
226 226
227 void ExtractMalwareFeaturesDone( 227 void ExtractMalwareFeaturesDone(
228 bool success, 228 bool success,
229 scoped_ptr<ClientMalwareRequest> request) { 229 scoped_ptr<ClientMalwareRequest> request) {
230 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 230 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
231 ASSERT_EQ(0U, success_.count(request.get())); 231 ASSERT_EQ(0U, success_.count(request.get()));
232 // The pointer doesn't really belong to us. It belongs to 232 // The pointer doesn't really belong to us. It belongs to
233 // the test case which passed it to ExtractMalwareFeatures above. 233 // the test case which passed it to ExtractMalwareFeatures above.
234 success_[request.release()] = success; 234 success_[request.release()] = success;
235 if (--num_pending_ == 0) { 235 if (--num_pending_ == 0) {
236 base::MessageLoopForUI::current()->Quit(); 236 base::MessageLoopForUI::current()->QuitWhenIdle();
237 } 237 }
238 } 238 }
239 }; 239 };
240 240
241 TEST_F(BrowserFeatureExtractorTest, UrlNotInHistory) { 241 TEST_F(BrowserFeatureExtractorTest, UrlNotInHistory) {
242 ClientPhishingRequest request; 242 ClientPhishingRequest request;
243 SimpleNavigateAndCommit(GURL("http://www.google.com")); 243 SimpleNavigateAndCommit(GURL("http://www.google.com"));
244 request.set_url("http://www.google.com/"); 244 request.set_url("http://www.google.com/");
245 request.set_client_score(0.5); 245 request.set_client_score(0.5);
246 EXPECT_FALSE(ExtractFeatures(&request)); 246 EXPECT_FALSE(ExtractFeatures(&request));
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // First ip is good but all the others are bad. 651 // First ip is good but all the others are bad.
652 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); 652 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0));
653 } 653 }
654 654
655 ExtractMalwareFeatures(&request); 655 ExtractMalwareFeatures(&request);
656 // The number of IP matched url we store is capped at 5 IPs per request. 656 // The number of IP matched url we store is capped at 5 IPs per request.
657 EXPECT_EQ(5, request.bad_ip_url_info_size()); 657 EXPECT_EQ(5, request.bad_ip_url_info_size());
658 } 658 }
659 659
660 } // namespace safe_browsing 660 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698