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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_browsertest.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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 // There shouldn't be any extra jobs. 313 // There shouldn't be any extra jobs.
314 EXPECT_LE(num_jobs_started_, num_jobs_to_wait_for_); 314 EXPECT_LE(num_jobs_started_, num_jobs_to_wait_for_);
315 315
316 // Should never be greater, but if it is, go ahead and exit the message loop 316 // Should never be greater, but if it is, go ahead and exit the message loop
317 // to try and avoid hanging. 317 // to try and avoid hanging.
318 if (num_jobs_started_ >= num_jobs_to_wait_for_) { 318 if (num_jobs_started_ >= num_jobs_to_wait_for_) {
319 last_num_jobs_to_wait_for_ = num_jobs_to_wait_for_; 319 last_num_jobs_to_wait_for_ = num_jobs_to_wait_for_;
320 num_jobs_to_wait_for_ = 0; 320 num_jobs_to_wait_for_ = 0;
321 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 321 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
322 base::MessageLoop::QuitClosure()); 322 base::MessageLoop::QuitWhenIdleClosure());
323 } 323 }
324 } 324 }
325 325
326 // static 326 // static
327 void URLRequestTimeoutOnDemandJob::FailOrAbandonJobsOnIOThread( 327 void URLRequestTimeoutOnDemandJob::FailOrAbandonJobsOnIOThread(
328 int expected_num_jobs, 328 int expected_num_jobs,
329 EndJobOperation end_job_operation, 329 EndJobOperation end_job_operation,
330 const net::SSLInfo& ssl_info) { 330 const net::SSLInfo& ssl_info) {
331 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 331 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
332 ASSERT_LT(0, expected_num_jobs); 332 ASSERT_LT(0, expected_num_jobs);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 const content::NotificationSource& source, 644 const content::NotificationSource& source,
645 const content::NotificationDetails& details) { 645 const content::NotificationDetails& details) {
646 ASSERT_EQ(type, content::NOTIFICATION_LOAD_STOP); 646 ASSERT_EQ(type, content::NOTIFICATION_LOAD_STOP);
647 content::NavigationController* controller = 647 content::NavigationController* controller =
648 content::Source<content::NavigationController>(source).ptr(); 648 content::Source<content::NavigationController>(source).ptr();
649 ++num_navigations_; 649 ++num_navigations_;
650 ++tab_navigation_map_[controller->GetWebContents()]; 650 ++tab_navigation_map_[controller->GetWebContents()];
651 if (waiting_for_navigation_ && 651 if (waiting_for_navigation_ &&
652 num_navigations_to_wait_for_ == num_navigations_) { 652 num_navigations_to_wait_for_ == num_navigations_) {
653 waiting_for_navigation_ = false; 653 waiting_for_navigation_ = false;
654 base::MessageLoopForUI::current()->Quit(); 654 base::MessageLoopForUI::current()->QuitWhenIdle();
655 } 655 }
656 } 656 }
657 657
658 // This observer creates a list of loading tabs, and then waits for them all 658 // This observer creates a list of loading tabs, and then waits for them all
659 // to stop loading and have the kInternetConnectedTitle. 659 // to stop loading and have the kInternetConnectedTitle.
660 // 660 //
661 // This is for the specific purpose of observing tabs time out after logging in 661 // This is for the specific purpose of observing tabs time out after logging in
662 // to a captive portal, which will then cause them to reload. 662 // to a captive portal, which will then cause them to reload.
663 // MultiNavigationObserver is insufficient for this because there may or may not 663 // MultiNavigationObserver is insufficient for this because there may or may not
664 // be a LOAD_STOP event between the timeout and the reload. 664 // be a LOAD_STOP event between the timeout and the reload.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 ASSERT_EQ(0u, tabs_navigated_to_final_destination_.count(contents)); 734 ASSERT_EQ(0u, tabs_navigated_to_final_destination_.count(contents));
735 735
736 if (contents->GetTitle() != base::ASCIIToUTF16(kInternetConnectedTitle)) 736 if (contents->GetTitle() != base::ASCIIToUTF16(kInternetConnectedTitle))
737 return; 737 return;
738 tabs_navigated_to_final_destination_.insert(contents); 738 tabs_navigated_to_final_destination_.insert(contents);
739 739
740 if (waiting_for_navigation_ && 740 if (waiting_for_navigation_ &&
741 tabs_needing_navigation_.size() == 741 tabs_needing_navigation_.size() ==
742 tabs_navigated_to_final_destination_.size()) { 742 tabs_navigated_to_final_destination_.size()) {
743 waiting_for_navigation_ = false; 743 waiting_for_navigation_ = false;
744 base::MessageLoopForUI::current()->Quit(); 744 base::MessageLoopForUI::current()->QuitWhenIdle();
745 } 745 }
746 } 746 }
747 747
748 // An observer for watching the CaptivePortalService. It tracks the last 748 // An observer for watching the CaptivePortalService. It tracks the last
749 // received result and the total number of received results. 749 // received result and the total number of received results.
750 class CaptivePortalObserver : public content::NotificationObserver { 750 class CaptivePortalObserver : public content::NotificationObserver {
751 public: 751 public:
752 explicit CaptivePortalObserver(Profile* profile); 752 explicit CaptivePortalObserver(Profile* profile);
753 753
754 // Runs the message loop until exactly |update_count| captive portal 754 // Runs the message loop until exactly |update_count| captive portal
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 EXPECT_EQ(captive_portal_result_, results->previous_result); 828 EXPECT_EQ(captive_portal_result_, results->previous_result);
829 EXPECT_EQ(captive_portal_service_->last_detection_result(), 829 EXPECT_EQ(captive_portal_service_->last_detection_result(),
830 results->result); 830 results->result);
831 831
832 captive_portal_result_ = results->result; 832 captive_portal_result_ = results->result;
833 ++num_results_received_; 833 ++num_results_received_;
834 834
835 if (waiting_for_result_ && 835 if (waiting_for_result_ &&
836 num_results_to_wait_for_ == num_results_received_) { 836 num_results_to_wait_for_ == num_results_received_) {
837 waiting_for_result_ = false; 837 waiting_for_result_ = false;
838 base::MessageLoop::current()->Quit(); 838 base::MessageLoop::current()->QuitWhenIdle();
839 } 839 }
840 } 840 }
841 841
842 // This observer waits for the SSLErrorHandler to start an interstitial timer 842 // This observer waits for the SSLErrorHandler to start an interstitial timer
843 // for the given web contents. 843 // for the given web contents.
844 class SSLInterstitialTimerObserver { 844 class SSLInterstitialTimerObserver {
845 public: 845 public:
846 explicit SSLInterstitialTimerObserver(content::WebContents* web_contents); 846 explicit SSLInterstitialTimerObserver(content::WebContents* web_contents);
847 ~SSLInterstitialTimerObserver(); 847 ~SSLInterstitialTimerObserver();
848 848
(...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 2871
2872 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, 2872 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD,
2873 GetStateOfTabReloaderAt(browser(), broken_tab_index)); 2873 GetStateOfTabReloaderAt(browser(), broken_tab_index));
2874 2874
2875 WaitForInterstitialAttach(broken_tab_contents); 2875 WaitForInterstitialAttach(broken_tab_contents);
2876 portal_observer.WaitForResults(1); 2876 portal_observer.WaitForResults(1);
2877 2877
2878 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, 2878 EXPECT_EQ(SSLBlockingPage::kTypeForTesting,
2879 GetInterstitialType(broken_tab_contents)); 2879 GetInterstitialType(broken_tab_contents));
2880 } 2880 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698