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;
const int kRequestTimeoutSec = 10;
// 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.
// TODO (ygorshenin@): use exponential backoff or normally distributed
......@@ -354,12 +354,11 @@ void NetworkPortalDetector::OnPortalDetectionCompleted(
state.response_code = results.response_code;
switch (results.result) {
case captive_portal::RESULT_NO_RESPONSE:
if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED;
SetCaptivePortalState(active_network, state);
} else if (attempt_count_ >= kMaxRequestAttempts) {
// Take into account shill's detection results.
if (active_network->restricted_pool()) {
if (attempt_count_ >= kMaxRequestAttempts) {
if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED;
} else if (active_network->restricted_pool()) {
// Take into account shill's detection results.
state.status = CAPTIVE_PORTAL_STATUS_PORTAL;
LOG(WARNING) << "Network " << active_network->unique_id() << " "
<< "is marked as "
......
......@@ -424,10 +424,29 @@ TEST_F(NetworkPortalDetectorTest, AllAttemptsFailed) {
TEST_F(NetworkPortalDetectorTest, ProxyAuthRequired) {
ASSERT_TRUE(is_state_idle());
set_min_time_between_attempts(base::TimeDelta());
SetConnected(wifi1_network());
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());
CheckPortalState(
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