| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 // There shouldn't be any extra jobs. | 284 // There shouldn't be any extra jobs. |
| 285 EXPECT_LE(num_jobs_started_, num_jobs_to_wait_for_); | 285 EXPECT_LE(num_jobs_started_, num_jobs_to_wait_for_); |
| 286 | 286 |
| 287 // Should never be greater, but if it is, go ahead and exit the message loop | 287 // Should never be greater, but if it is, go ahead and exit the message loop |
| 288 // to try and avoid hanging. | 288 // to try and avoid hanging. |
| 289 if (num_jobs_started_ >= num_jobs_to_wait_for_) { | 289 if (num_jobs_started_ >= num_jobs_to_wait_for_) { |
| 290 last_num_jobs_to_wait_for_ = num_jobs_to_wait_for_; | 290 last_num_jobs_to_wait_for_ = num_jobs_to_wait_for_; |
| 291 num_jobs_to_wait_for_ = 0; | 291 num_jobs_to_wait_for_ = 0; |
| 292 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 292 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 293 MessageLoop::QuitClosure()); | 293 base::MessageLoop::QuitClosure()); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 | 296 |
| 297 // static | 297 // static |
| 298 void URLRequestTimeoutOnDemandJob::FailOrAbandonJobsOnIOThread( | 298 void URLRequestTimeoutOnDemandJob::FailOrAbandonJobsOnIOThread( |
| 299 int expected_num_jobs, | 299 int expected_num_jobs, |
| 300 EndJobOperation end_job_operation) { | 300 EndJobOperation end_job_operation) { |
| 301 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 301 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 302 ASSERT_LT(0, expected_num_jobs); | 302 ASSERT_LT(0, expected_num_jobs); |
| 303 EXPECT_EQ(last_num_jobs_to_wait_for_, expected_num_jobs); | 303 EXPECT_EQ(last_num_jobs_to_wait_for_, expected_num_jobs); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 const content::NotificationSource& source, | 572 const content::NotificationSource& source, |
| 573 const content::NotificationDetails& details) { | 573 const content::NotificationDetails& details) { |
| 574 ASSERT_EQ(type, content::NOTIFICATION_LOAD_STOP); | 574 ASSERT_EQ(type, content::NOTIFICATION_LOAD_STOP); |
| 575 content::NavigationController* controller = | 575 content::NavigationController* controller = |
| 576 content::Source<content::NavigationController>(source).ptr(); | 576 content::Source<content::NavigationController>(source).ptr(); |
| 577 ++num_navigations_; | 577 ++num_navigations_; |
| 578 ++tab_navigation_map_[controller->GetWebContents()]; | 578 ++tab_navigation_map_[controller->GetWebContents()]; |
| 579 if (waiting_for_navigation_ && | 579 if (waiting_for_navigation_ && |
| 580 num_navigations_to_wait_for_ == num_navigations_) { | 580 num_navigations_to_wait_for_ == num_navigations_) { |
| 581 waiting_for_navigation_ = false; | 581 waiting_for_navigation_ = false; |
| 582 MessageLoopForUI::current()->Quit(); | 582 base::MessageLoopForUI::current()->Quit(); |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 // This observer creates a list of loading tabs, and then waits for them all | 586 // This observer creates a list of loading tabs, and then waits for them all |
| 587 // to stop loading and have the kInternetConnectedTitle. | 587 // to stop loading and have the kInternetConnectedTitle. |
| 588 // | 588 // |
| 589 // This is for the specific purpose of observing tabs time out after logging in | 589 // This is for the specific purpose of observing tabs time out after logging in |
| 590 // to a captive portal, which will then cause them to reload. | 590 // to a captive portal, which will then cause them to reload. |
| 591 // MultiNavigationObserver is insufficient for this because there may or may not | 591 // MultiNavigationObserver is insufficient for this because there may or may not |
| 592 // be a LOAD_STOP event between the timeout and the reload. | 592 // be a LOAD_STOP event between the timeout and the reload. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 ASSERT_EQ(0u, tabs_navigated_to_final_destination_.count(contents)); | 661 ASSERT_EQ(0u, tabs_navigated_to_final_destination_.count(contents)); |
| 662 | 662 |
| 663 if (contents->GetTitle() != ASCIIToUTF16(kInternetConnectedTitle)) | 663 if (contents->GetTitle() != ASCIIToUTF16(kInternetConnectedTitle)) |
| 664 return; | 664 return; |
| 665 tabs_navigated_to_final_destination_.insert(contents); | 665 tabs_navigated_to_final_destination_.insert(contents); |
| 666 | 666 |
| 667 if (waiting_for_navigation_ && | 667 if (waiting_for_navigation_ && |
| 668 tabs_needing_navigation_.size() == | 668 tabs_needing_navigation_.size() == |
| 669 tabs_navigated_to_final_destination_.size()) { | 669 tabs_navigated_to_final_destination_.size()) { |
| 670 waiting_for_navigation_ = false; | 670 waiting_for_navigation_ = false; |
| 671 MessageLoopForUI::current()->Quit(); | 671 base::MessageLoopForUI::current()->Quit(); |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 | 674 |
| 675 // An observer for watching the CaptivePortalService. It tracks the last | 675 // An observer for watching the CaptivePortalService. It tracks the last |
| 676 // received result and the total number of received results. | 676 // received result and the total number of received results. |
| 677 class CaptivePortalObserver : public content::NotificationObserver { | 677 class CaptivePortalObserver : public content::NotificationObserver { |
| 678 public: | 678 public: |
| 679 explicit CaptivePortalObserver(Profile* profile); | 679 explicit CaptivePortalObserver(Profile* profile); |
| 680 | 680 |
| 681 // Runs the message loop until until at exactly |update_count| capitive portal | 681 // Runs the message loop until until at exactly |update_count| capitive portal |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 EXPECT_EQ(captive_portal_result_, results->previous_result); | 755 EXPECT_EQ(captive_portal_result_, results->previous_result); |
| 756 EXPECT_EQ(captive_portal_service_->last_detection_result(), | 756 EXPECT_EQ(captive_portal_service_->last_detection_result(), |
| 757 results->result); | 757 results->result); |
| 758 | 758 |
| 759 captive_portal_result_ = results->result; | 759 captive_portal_result_ = results->result; |
| 760 ++num_results_received_; | 760 ++num_results_received_; |
| 761 | 761 |
| 762 if (waiting_for_result_ && | 762 if (waiting_for_result_ && |
| 763 num_results_to_wait_for_ == num_results_received_) { | 763 num_results_to_wait_for_ == num_results_received_) { |
| 764 waiting_for_result_ = false; | 764 waiting_for_result_ = false; |
| 765 MessageLoop::current()->Quit(); | 765 base::MessageLoop::current()->Quit(); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 | 768 |
| 769 // Adds an HSTS rule for |host|, so that all HTTP requests sent to it will | 769 // Adds an HSTS rule for |host|, so that all HTTP requests sent to it will |
| 770 // be switched to HTTPS requests. | 770 // be switched to HTTPS requests. |
| 771 void AddHstsHost(net::URLRequestContextGetter* context_getter, | 771 void AddHstsHost(net::URLRequestContextGetter* context_getter, |
| 772 const std::string& host) { | 772 const std::string& host) { |
| 773 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 773 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 774 net::TransportSecurityState* transport_security_state = | 774 net::TransportSecurityState* transport_security_state = |
| 775 context_getter->GetURLRequestContext()->transport_security_state(); | 775 context_getter->GetURLRequestContext()->transport_security_state(); |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2197 base::Bind(&AddHstsHost, | 2197 base::Bind(&AddHstsHost, |
| 2198 make_scoped_refptr(browser()->profile()->GetRequestContext()), | 2198 make_scoped_refptr(browser()->profile()->GetRequestContext()), |
| 2199 http_timeout_url.host())); | 2199 http_timeout_url.host())); |
| 2200 | 2200 |
| 2201 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); | 2201 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); |
| 2202 Login(browser(), 1, 0); | 2202 Login(browser(), 1, 0); |
| 2203 FailLoadsAfterLogin(browser(), 1); | 2203 FailLoadsAfterLogin(browser(), 1); |
| 2204 } | 2204 } |
| 2205 | 2205 |
| 2206 } // namespace captive_portal | 2206 } // namespace captive_portal |
| OLD | NEW |