Fixed portal detector behaviour for proxied network.

Active network is marked as PROXY_AUTH_REQUIRED only after 3
consecutive failing attempts. This gives enough time for the network
stack to connect to the proxied network after proxy authenication.

BUG=174061
TEST=unit_tests:NetworkPortalDetectorTest.*


Review URL: https://chromiumcodereview.appspot.com/12263006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182385 0039d316-1c4b-4281-b951-d872f2087c98
parent edd3cd19
...@@ -36,7 +36,7 @@ const int kMinTimeBetweenAttemptsSec = 3; ...@@ -36,7 +36,7 @@ const int kMinTimeBetweenAttemptsSec = 3;
const int kRequestTimeoutSec = 10; const int kRequestTimeoutSec = 10;
// Delay before portal detection caused by changes in proxy settings. // Delay before portal detection caused by changes in proxy settings.
const int kProxyChangeDelayMs = 500; const int kProxyChangeDelayMs = 1000;
// Delay between consecutive portal checks for a network in lazy mode. // Delay between consecutive portal checks for a network in lazy mode.
// TODO (ygorshenin@): use exponential backoff or normally distributed // TODO (ygorshenin@): use exponential backoff or normally distributed
...@@ -354,12 +354,11 @@ void NetworkPortalDetector::OnPortalDetectionCompleted( ...@@ -354,12 +354,11 @@ void NetworkPortalDetector::OnPortalDetectionCompleted(
state.response_code = results.response_code; state.response_code = results.response_code;
switch (results.result) { switch (results.result) {
case captive_portal::RESULT_NO_RESPONSE: case captive_portal::RESULT_NO_RESPONSE:
if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { if (attempt_count_ >= kMaxRequestAttempts) {
state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
SetCaptivePortalState(active_network, state); state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED;
} else if (attempt_count_ >= kMaxRequestAttempts) { } else if (active_network->restricted_pool()) {
// Take into account shill's detection results. // Take into account shill's detection results.
if (active_network->restricted_pool()) {
state.status = CAPTIVE_PORTAL_STATUS_PORTAL; state.status = CAPTIVE_PORTAL_STATUS_PORTAL;
LOG(WARNING) << "Network " << active_network->unique_id() << " " LOG(WARNING) << "Network " << active_network->unique_id() << " "
<< "is marked as " << "is marked as "
......
...@@ -424,10 +424,29 @@ TEST_F(NetworkPortalDetectorTest, AllAttemptsFailed) { ...@@ -424,10 +424,29 @@ TEST_F(NetworkPortalDetectorTest, AllAttemptsFailed) {
TEST_F(NetworkPortalDetectorTest, ProxyAuthRequired) { TEST_F(NetworkPortalDetectorTest, ProxyAuthRequired) {
ASSERT_TRUE(is_state_idle()); ASSERT_TRUE(is_state_idle());
set_min_time_between_attempts(base::TimeDelta());
SetConnected(wifi1_network()); SetConnected(wifi1_network());
CompleteURLFetch(net::OK, 407, NULL); CompleteURLFetch(net::OK, 407, NULL);
ASSERT_EQ(1, attempt_count());
ASSERT_TRUE(is_state_portal_detection_pending());
CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1,
wifi1_network());
// To run CaptivePortalDetector::DetectCaptivePortal().
MessageLoop::current()->RunUntilIdle();
CompleteURLFetch(net::OK, 407, NULL);
ASSERT_EQ(2, attempt_count());
ASSERT_TRUE(is_state_portal_detection_pending());
CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1,
wifi1_network());
// To run CaptivePortalDetector::DetectCaptivePortal().
MessageLoop::current()->RunUntilIdle();
CompleteURLFetch(net::OK, 407, NULL);
ASSERT_EQ(3, attempt_count());
ASSERT_TRUE(is_state_idle()); ASSERT_TRUE(is_state_idle());
CheckPortalState( CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED, 407, NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED, 407,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment