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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
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/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 class AwaitCompletionHelper : public BrowsingDataRemover::Observer { 122 class AwaitCompletionHelper : public BrowsingDataRemover::Observer {
123 public: 123 public:
124 AwaitCompletionHelper() : start_(false), already_quit_(false) {} 124 AwaitCompletionHelper() : start_(false), already_quit_(false) {}
125 virtual ~AwaitCompletionHelper() {} 125 virtual ~AwaitCompletionHelper() {}
126 126
127 void BlockUntilNotified() { 127 void BlockUntilNotified() {
128 if (!already_quit_) { 128 if (!already_quit_) {
129 DCHECK(!start_); 129 DCHECK(!start_);
130 start_ = true; 130 start_ = true;
131 MessageLoop::current()->Run(); 131 base::MessageLoop::current()->Run();
132 } else { 132 } else {
133 DCHECK(!start_); 133 DCHECK(!start_);
134 already_quit_ = false; 134 already_quit_ = false;
135 } 135 }
136 } 136 }
137 137
138 void Notify() { 138 void Notify() {
139 if (start_) { 139 if (start_) {
140 DCHECK(!already_quit_); 140 DCHECK(!already_quit_);
141 MessageLoop::current()->Quit(); 141 base::MessageLoop::current()->Quit();
142 start_ = false; 142 start_ = false;
143 } else { 143 } else {
144 DCHECK(!already_quit_); 144 DCHECK(!already_quit_);
145 already_quit_ = true; 145 already_quit_ = true;
146 } 146 }
147 } 147 }
148 148
149 protected: 149 protected:
150 // BrowsingDataRemover::Observer implementation. 150 // BrowsingDataRemover::Observer implementation.
151 virtual void OnBrowsingDataRemoverDone() OVERRIDE { 151 virtual void OnBrowsingDataRemoverDone() OVERRIDE {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 229 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
230 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { 230 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester {
231 public: 231 public:
232 RemoveSafeBrowsingCookieTester() 232 RemoveSafeBrowsingCookieTester()
233 : browser_process_(TestingBrowserProcess::GetGlobal()) { 233 : browser_process_(TestingBrowserProcess::GetGlobal()) {
234 scoped_refptr<SafeBrowsingService> sb_service = 234 scoped_refptr<SafeBrowsingService> sb_service =
235 SafeBrowsingService::CreateSafeBrowsingService(); 235 SafeBrowsingService::CreateSafeBrowsingService();
236 browser_process_->SetSafeBrowsingService(sb_service); 236 browser_process_->SetSafeBrowsingService(sb_service);
237 sb_service->Initialize(); 237 sb_service->Initialize();
238 MessageLoop::current()->RunUntilIdle(); 238 base::MessageLoop::current()->RunUntilIdle();
239 239
240 // Create a cookiemonster that does not have persistant storage, and replace 240 // Create a cookiemonster that does not have persistant storage, and replace
241 // the SafeBrowsingService created one with it. 241 // the SafeBrowsingService created one with it.
242 net::CookieStore* monster = new net::CookieMonster(NULL, NULL); 242 net::CookieStore* monster = new net::CookieMonster(NULL, NULL);
243 sb_service->url_request_context()->GetURLRequestContext()-> 243 sb_service->url_request_context()->GetURLRequestContext()->
244 set_cookie_store(monster); 244 set_cookie_store(monster);
245 SetMonster(monster); 245 SetMonster(monster);
246 } 246 }
247 247
248 virtual ~RemoveSafeBrowsingCookieTester() { 248 virtual ~RemoveSafeBrowsingCookieTester() {
249 browser_process_->safe_browsing_service()->ShutDown(); 249 browser_process_->safe_browsing_service()->ShutDown();
250 MessageLoop::current()->RunUntilIdle(); 250 base::MessageLoop::current()->RunUntilIdle();
251 browser_process_->SetSafeBrowsingService(NULL); 251 browser_process_->SetSafeBrowsingService(NULL);
252 } 252 }
253 253
254 private: 254 private:
255 TestingBrowserProcess* browser_process_; 255 TestingBrowserProcess* browser_process_;
256 256
257 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); 257 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester);
258 }; 258 };
259 #endif 259 #endif
260 260
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 profile.SetRawInfo(autofill::NAME_FIRST, ASCIIToUTF16("Bob")); 401 profile.SetRawInfo(autofill::NAME_FIRST, ASCIIToUTF16("Bob"));
402 profile.SetRawInfo(autofill::NAME_LAST, ASCIIToUTF16("Smith")); 402 profile.SetRawInfo(autofill::NAME_LAST, ASCIIToUTF16("Smith"));
403 profile.SetRawInfo(autofill::ADDRESS_HOME_ZIP, ASCIIToUTF16("94043")); 403 profile.SetRawInfo(autofill::ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"));
404 profile.SetRawInfo(autofill::EMAIL_ADDRESS, 404 profile.SetRawInfo(autofill::EMAIL_ADDRESS,
405 ASCIIToUTF16("sue@example.com")); 405 ASCIIToUTF16("sue@example.com"));
406 profile.SetRawInfo(autofill::COMPANY_NAME, ASCIIToUTF16("Company X")); 406 profile.SetRawInfo(autofill::COMPANY_NAME, ASCIIToUTF16("Company X"));
407 407
408 std::vector<autofill::AutofillProfile> profiles; 408 std::vector<autofill::AutofillProfile> profiles;
409 profiles.push_back(profile); 409 profiles.push_back(profile);
410 personal_data_manager_->SetProfiles(&profiles); 410 personal_data_manager_->SetProfiles(&profiles);
411 MessageLoop::current()->Run(); 411 base::MessageLoop::current()->Run();
412 412
413 autofill::CreditCard card; 413 autofill::CreditCard card;
414 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, 414 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER,
415 ASCIIToUTF16("1234-5678-9012-3456")); 415 ASCIIToUTF16("1234-5678-9012-3456"));
416 416
417 std::vector<autofill::CreditCard> cards; 417 std::vector<autofill::CreditCard> cards;
418 cards.push_back(card); 418 cards.push_back(card);
419 personal_data_manager_->SetCreditCards(&cards); 419 personal_data_manager_->SetCreditCards(&cards);
420 MessageLoop::current()->Run(); 420 base::MessageLoop::current()->Run();
421 } 421 }
422 422
423 private: 423 private:
424 virtual void OnPersonalDataChanged() OVERRIDE { 424 virtual void OnPersonalDataChanged() OVERRIDE {
425 MessageLoop::current()->Quit(); 425 base::MessageLoop::current()->Quit();
426 } 426 }
427 427
428 autofill::PersonalDataManager* personal_data_manager_; 428 autofill::PersonalDataManager* personal_data_manager_;
429 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); 429 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester);
430 }; 430 };
431 431
432 class RemoveLocalStorageTester { 432 class RemoveLocalStorageTester {
433 public: 433 public:
434 explicit RemoveLocalStorageTester(TestingProfile* profile) 434 explicit RemoveLocalStorageTester(TestingProfile* profile)
435 : profile_(profile), dom_storage_context_(NULL) { 435 : profile_(profile), dom_storage_context_(NULL) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 registrar_.RemoveAll(); 608 registrar_.RemoveAll();
609 } 609 }
610 610
611 private: 611 private:
612 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_; 612 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_;
613 content::NotificationRegistrar registrar_; 613 content::NotificationRegistrar registrar_;
614 614
615 // message_loop_, as well as all the threads associated with it must be 615 // message_loop_, as well as all the threads associated with it must be
616 // defined before profile_ to prevent explosions. Oh how I love C++. 616 // defined before profile_ to prevent explosions. Oh how I love C++.
617 MessageLoopForUI message_loop_; 617 base::MessageLoopForUI message_loop_;
618 content::TestBrowserThread ui_thread_; 618 content::TestBrowserThread ui_thread_;
619 content::TestBrowserThread db_thread_; 619 content::TestBrowserThread db_thread_;
620 content::TestBrowserThread webkit_thread_; 620 content::TestBrowserThread webkit_thread_;
621 content::TestBrowserThread file_thread_; 621 content::TestBrowserThread file_thread_;
622 content::TestBrowserThread file_user_blocking_thread_; 622 content::TestBrowserThread file_user_blocking_thread_;
623 content::TestBrowserThread io_thread_; 623 content::TestBrowserThread io_thread_;
624 scoped_ptr<TestingProfile> profile_; 624 scoped_ptr<TestingProfile> profile_;
625 scoped_refptr<quota::MockQuotaManager> quota_manager_; 625 scoped_refptr<quota::MockQuotaManager> quota_manager_;
626 626
627 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); 627 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest);
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 ASSERT_TRUE(tester.HasProfile()); 1330 ASSERT_TRUE(tester.HasProfile());
1331 1331
1332 BlockUntilBrowsingDataRemoved( 1332 BlockUntilBrowsingDataRemoved(
1333 BrowsingDataRemover::EVERYTHING, 1333 BrowsingDataRemover::EVERYTHING,
1334 BrowsingDataRemover::REMOVE_FORM_DATA, false); 1334 BrowsingDataRemover::REMOVE_FORM_DATA, false);
1335 1335
1336 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); 1336 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask());
1337 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); 1337 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask());
1338 ASSERT_FALSE(tester.HasProfile()); 1338 ASSERT_FALSE(tester.HasProfile());
1339 } 1339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698