| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/net/network_portal_detector_impl.h" | 5 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const int kProxyChangeDelaySec = 1; | 33 const int kProxyChangeDelaySec = 1; |
| 34 | 34 |
| 35 const NetworkState* DefaultNetwork() { | 35 const NetworkState* DefaultNetwork() { |
| 36 return NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); | 36 return NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool InSession() { | 39 bool InSession() { |
| 40 return UserManager::IsInitialized() && UserManager::Get()->IsUserLoggedIn(); | 40 return UserManager::IsInitialized() && UserManager::Get()->IsUserLoggedIn(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void RecordDetectionResult(NetworkPortalDetector::CaptivePortalStatus status) { | 43 void RecordDetectionResult(captive_portal::CaptivePortalStatus status) { |
| 44 if (InSession()) { | 44 if (InSession()) { |
| 45 UMA_HISTOGRAM_ENUMERATION( | 45 UMA_HISTOGRAM_ENUMERATION( |
| 46 NetworkPortalDetectorImpl::kSessionDetectionResultHistogram, | 46 NetworkPortalDetectorImpl::kSessionDetectionResultHistogram, |
| 47 status, | 47 status, |
| 48 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 48 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 49 } else { | 49 } else { |
| 50 UMA_HISTOGRAM_ENUMERATION( | 50 UMA_HISTOGRAM_ENUMERATION( |
| 51 NetworkPortalDetectorImpl::kOobeDetectionResultHistogram, | 51 NetworkPortalDetectorImpl::kOobeDetectionResultHistogram, |
| 52 status, | 52 status, |
| 53 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 53 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 void RecordDetectionDuration(const base::TimeDelta& duration) { | 57 void RecordDetectionDuration(const base::TimeDelta& duration) { |
| 58 if (InSession()) { | 58 if (InSession()) { |
| 59 UMA_HISTOGRAM_MEDIUM_TIMES( | 59 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 60 NetworkPortalDetectorImpl::kSessionDetectionDurationHistogram, | 60 NetworkPortalDetectorImpl::kSessionDetectionDurationHistogram, |
| 61 duration); | 61 duration); |
| 62 } else { | 62 } else { |
| 63 UMA_HISTOGRAM_MEDIUM_TIMES( | 63 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 64 NetworkPortalDetectorImpl::kOobeDetectionDurationHistogram, duration); | 64 NetworkPortalDetectorImpl::kOobeDetectionDurationHistogram, duration); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void RecordDiscrepancyWithShill( | 68 void RecordDiscrepancyWithShill( |
| 69 const NetworkState* network, | 69 const NetworkState* network, |
| 70 const NetworkPortalDetector::CaptivePortalStatus status) { | 70 const captive_portal::CaptivePortalStatus status) { |
| 71 if (InSession()) { | 71 if (InSession()) { |
| 72 if (network->connection_state() == shill::kStateOnline) { | 72 if (network->connection_state() == shill::kStateOnline) { |
| 73 UMA_HISTOGRAM_ENUMERATION( | 73 UMA_HISTOGRAM_ENUMERATION( |
| 74 NetworkPortalDetectorImpl::kSessionShillOnlineHistogram, | 74 NetworkPortalDetectorImpl::kSessionShillOnlineHistogram, |
| 75 status, | 75 status, |
| 76 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 76 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 77 } else if (network->connection_state() == shill::kStatePortal) { | 77 } else if (network->connection_state() == shill::kStatePortal) { |
| 78 UMA_HISTOGRAM_ENUMERATION( | 78 UMA_HISTOGRAM_ENUMERATION( |
| 79 NetworkPortalDetectorImpl::kSessionShillPortalHistogram, | 79 NetworkPortalDetectorImpl::kSessionShillPortalHistogram, |
| 80 status, | 80 status, |
| 81 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 81 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 82 } else if (network->connection_state() == shill::kStateOffline) { | 82 } else if (network->connection_state() == shill::kStateOffline) { |
| 83 UMA_HISTOGRAM_ENUMERATION( | 83 UMA_HISTOGRAM_ENUMERATION( |
| 84 NetworkPortalDetectorImpl::kSessionShillOfflineHistogram, | 84 NetworkPortalDetectorImpl::kSessionShillOfflineHistogram, |
| 85 status, | 85 status, |
| 86 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 86 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 87 } | 87 } |
| 88 } else { | 88 } else { |
| 89 if (network->connection_state() == shill::kStateOnline) { | 89 if (network->connection_state() == shill::kStateOnline) { |
| 90 UMA_HISTOGRAM_ENUMERATION( | 90 UMA_HISTOGRAM_ENUMERATION( |
| 91 NetworkPortalDetectorImpl::kOobeShillOnlineHistogram, | 91 NetworkPortalDetectorImpl::kOobeShillOnlineHistogram, |
| 92 status, | 92 status, |
| 93 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 93 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 94 } else if (network->connection_state() == shill::kStatePortal) { | 94 } else if (network->connection_state() == shill::kStatePortal) { |
| 95 UMA_HISTOGRAM_ENUMERATION( | 95 UMA_HISTOGRAM_ENUMERATION( |
| 96 NetworkPortalDetectorImpl::kOobeShillPortalHistogram, | 96 NetworkPortalDetectorImpl::kOobeShillPortalHistogram, |
| 97 status, | 97 status, |
| 98 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 98 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 99 } else if (network->connection_state() == shill::kStateOffline) { | 99 } else if (network->connection_state() == shill::kStateOffline) { |
| 100 UMA_HISTOGRAM_ENUMERATION( | 100 UMA_HISTOGRAM_ENUMERATION( |
| 101 NetworkPortalDetectorImpl::kOobeShillOfflineHistogram, | 101 NetworkPortalDetectorImpl::kOobeShillOfflineHistogram, |
| 102 status, | 102 status, |
| 103 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 103 captive_portal::CAPTIVE_PORTAL_STATUS_COUNT); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 void RecordPortalToOnlineTransition(const base::TimeDelta& duration) { | 108 void RecordPortalToOnlineTransition(const base::TimeDelta& duration) { |
| 109 if (InSession()) { | 109 if (InSession()) { |
| 110 UMA_HISTOGRAM_LONG_TIMES( | 110 UMA_HISTOGRAM_LONG_TIMES( |
| 111 NetworkPortalDetectorImpl::kSessionPortalToOnlineHistogram, | 111 NetworkPortalDetectorImpl::kSessionPortalToOnlineHistogram, |
| 112 duration); | 112 duration); |
| 113 } else { | 113 } else { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 const NetworkState* default_network) { | 256 const NetworkState* default_network) { |
| 257 DCHECK(CalledOnValidThread()); | 257 DCHECK(CalledOnValidThread()); |
| 258 | 258 |
| 259 if (!default_network) { | 259 if (!default_network) { |
| 260 default_network_name_.clear(); | 260 default_network_name_.clear(); |
| 261 default_network_id_.clear(); | 261 default_network_id_.clear(); |
| 262 | 262 |
| 263 StopDetection(); | 263 StopDetection(); |
| 264 | 264 |
| 265 CaptivePortalState state; | 265 CaptivePortalState state; |
| 266 state.status = CAPTIVE_PORTAL_STATUS_OFFLINE; | 266 state.status = captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE; |
| 267 OnDetectionCompleted(NULL, state); | 267 OnDetectionCompleted(NULL, state); |
| 268 return; | 268 return; |
| 269 } | 269 } |
| 270 | 270 |
| 271 default_network_name_ = default_network->name(); | 271 default_network_name_ = default_network->name(); |
| 272 default_network_id_ = default_network->guid(); | 272 default_network_id_ = default_network->guid(); |
| 273 | 273 |
| 274 bool network_changed = (default_service_path_ != default_network->path()); | 274 bool network_changed = (default_service_path_ != default_network->path()); |
| 275 default_service_path_ = default_network->path(); | 275 default_service_path_ = default_network->path(); |
| 276 | 276 |
| 277 bool connection_state_changed = | 277 bool connection_state_changed = |
| 278 (default_connection_state_ != default_network->connection_state()); | 278 (default_connection_state_ != default_network->connection_state()); |
| 279 default_connection_state_ = default_network->connection_state(); | 279 default_connection_state_ = default_network->connection_state(); |
| 280 | 280 |
| 281 if (network_changed || connection_state_changed) | 281 if (network_changed || connection_state_changed) |
| 282 StopDetection(); | 282 StopDetection(); |
| 283 | 283 |
| 284 if (CanPerformAttempt() && | 284 if (CanPerformAttempt() && |
| 285 NetworkState::StateIsConnected(default_connection_state_)) { | 285 NetworkState::StateIsConnected(default_connection_state_)) { |
| 286 // Initiate Captive Portal detection if network's captive | 286 // Initiate Captive Portal detection if network's captive |
| 287 // portal state is unknown (e.g. for freshly created networks), | 287 // portal state is unknown (e.g. for freshly created networks), |
| 288 // offline or if network connection state was changed. | 288 // offline or if network connection state was changed. |
| 289 CaptivePortalState state = GetCaptivePortalState(default_network->path()); | 289 CaptivePortalState state = GetCaptivePortalState(default_network->path()); |
| 290 if (state.status == CAPTIVE_PORTAL_STATUS_UNKNOWN || | 290 if (state.status == captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN || |
| 291 state.status == CAPTIVE_PORTAL_STATUS_OFFLINE || | 291 state.status == captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE || |
| 292 (!network_changed && connection_state_changed)) { | 292 (!network_changed && connection_state_changed)) { |
| 293 ScheduleAttempt(base::TimeDelta()); | 293 ScheduleAttempt(base::TimeDelta()); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 int NetworkPortalDetectorImpl::AttemptCount() { return attempt_count_; } | 298 int NetworkPortalDetectorImpl::AttemptCount() { return attempt_count_; } |
| 299 | 299 |
| 300 base::TimeTicks NetworkPortalDetectorImpl::AttemptStartTime() { | 300 base::TimeTicks NetworkPortalDetectorImpl::AttemptStartTime() { |
| 301 return attempt_start_time_; | 301 return attempt_start_time_; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 << "id=" << default_network_id_; | 384 << "id=" << default_network_id_; |
| 385 | 385 |
| 386 captive_portal_detector_->Cancel(); | 386 captive_portal_detector_->Cancel(); |
| 387 CaptivePortalDetector::Results results; | 387 CaptivePortalDetector::Results results; |
| 388 results.result = captive_portal::RESULT_NO_RESPONSE; | 388 results.result = captive_portal::RESULT_NO_RESPONSE; |
| 389 OnAttemptCompleted(results); | 389 OnAttemptCompleted(results); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void NetworkPortalDetectorImpl::OnAttemptCompleted( | 392 void NetworkPortalDetectorImpl::OnAttemptCompleted( |
| 393 const CaptivePortalDetector::Results& results) { | 393 const CaptivePortalDetector::Results& results) { |
| 394 captive_portal::Result result = results.result; | 394 captive_portal::CaptivePortalResult result = results.result; |
| 395 int response_code = results.response_code; | 395 int response_code = results.response_code; |
| 396 | 396 |
| 397 DCHECK(CalledOnValidThread()); | 397 DCHECK(CalledOnValidThread()); |
| 398 DCHECK(is_checking_for_portal()); | 398 DCHECK(is_checking_for_portal()); |
| 399 | 399 |
| 400 VLOG(1) << "Detection attempt completed: " | 400 VLOG(1) << "Detection attempt completed: " |
| 401 << "name=" << default_network_name_ << ", " | 401 << "name=" << default_network_name_ << ", " |
| 402 << "id=" << default_network_id_ << ", " | 402 << "id=" << default_network_id_ << ", " |
| 403 << "result=" | 403 << "result=" |
| 404 << CaptivePortalDetector::CaptivePortalResultToString(results.result) | 404 << captive_portal::CaptivePortalResultToString(results.result) |
| 405 << ", " | 405 << ", " |
| 406 << "response_code=" << results.response_code; | 406 << "response_code=" << results.response_code; |
| 407 | 407 |
| 408 state_ = STATE_IDLE; | 408 state_ = STATE_IDLE; |
| 409 attempt_timeout_.Cancel(); | 409 attempt_timeout_.Cancel(); |
| 410 ++attempt_count_; | 410 ++attempt_count_; |
| 411 | 411 |
| 412 const NetworkState* network = DefaultNetwork(); | 412 const NetworkState* network = DefaultNetwork(); |
| 413 | 413 |
| 414 // If using a fake profile client, also fake being behind a captive portal | 414 // If using a fake profile client, also fake being behind a captive portal |
| 415 // if the default network is in portal state. | 415 // if the default network is in portal state. |
| 416 if (result != captive_portal::RESULT_NO_RESPONSE && | 416 if (result != captive_portal::RESULT_NO_RESPONSE && |
| 417 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface() && | 417 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface() && |
| 418 network && network->connection_state() == shill::kStatePortal) { | 418 network && network->connection_state() == shill::kStatePortal) { |
| 419 result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL; | 419 result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL; |
| 420 response_code = 200; | 420 response_code = 200; |
| 421 } | 421 } |
| 422 | 422 |
| 423 CaptivePortalState state; | 423 CaptivePortalState state; |
| 424 state.response_code = response_code; | 424 state.response_code = response_code; |
| 425 state.time = GetCurrentTimeTicks(); | 425 state.time = GetCurrentTimeTicks(); |
| 426 switch (result) { | 426 switch (result) { |
| 427 case captive_portal::RESULT_NO_RESPONSE: | 427 case captive_portal::RESULT_NO_RESPONSE: |
| 428 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { | 428 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { |
| 429 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; | 429 state.status = |
| 430 captive_portal::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; |
| 430 } else if (CanPerformAttempt()) { | 431 } else if (CanPerformAttempt()) { |
| 431 ScheduleAttempt(results.retry_after_delta); | 432 ScheduleAttempt(results.retry_after_delta); |
| 432 return; | 433 return; |
| 433 } else if (network && | 434 } else if (network && |
| 434 (network->connection_state() == shill::kStatePortal)) { | 435 (network->connection_state() == shill::kStatePortal)) { |
| 435 // Take into account shill's detection results. | 436 // Take into account shill's detection results. |
| 436 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; | 437 state.status = captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 437 LOG(WARNING) << "Network name=" << network->name() << ", " | 438 LOG(WARNING) << "Network name=" << network->name() << ", " |
| 438 << "id=" << network->guid() << " " | 439 << "id=" << network->guid() << " is marked as " |
| 439 << "is marked as " | 440 << captive_portal::CaptivePortalStatusString(state.status) |
| 440 << CaptivePortalStatusString(state.status) << " " | 441 << " despite no response from CaptivePortalDetector."; |
| 441 << "despite the fact that CaptivePortalDetector " | |
| 442 << "received no response"; | |
| 443 } else { | 442 } else { |
| 444 state.status = CAPTIVE_PORTAL_STATUS_OFFLINE; | 443 state.status = captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE; |
| 445 } | 444 } |
| 446 break; | 445 break; |
| 447 case captive_portal::RESULT_INTERNET_CONNECTED: | 446 case captive_portal::RESULT_INTERNET_CONNECTED: |
| 448 state.status = CAPTIVE_PORTAL_STATUS_ONLINE; | 447 state.status = captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE; |
| 449 break; | 448 break; |
| 450 case captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL: | 449 case captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL: |
| 451 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; | 450 state.status = captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 452 break; | 451 break; |
| 453 default: | 452 default: |
| 454 break; | 453 break; |
| 455 } | 454 } |
| 456 | 455 |
| 457 OnDetectionCompleted(network, state); | 456 OnDetectionCompleted(network, state); |
| 458 if (CanPerformAttempt() && strategy_->CanPerformAttemptAfterDetection()) | 457 if (CanPerformAttempt() && strategy_->CanPerformAttemptAfterDetection()) |
| 459 ScheduleAttempt(base::TimeDelta()); | 458 ScheduleAttempt(base::TimeDelta()); |
| 460 } | 459 } |
| 461 | 460 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 484 NotifyDetectionCompleted(network, state); | 483 NotifyDetectionCompleted(network, state); |
| 485 return; | 484 return; |
| 486 } | 485 } |
| 487 | 486 |
| 488 CaptivePortalStateMap::const_iterator it = | 487 CaptivePortalStateMap::const_iterator it = |
| 489 portal_state_map_.find(network->path()); | 488 portal_state_map_.find(network->path()); |
| 490 if (it == portal_state_map_.end() || it->second.status != state.status || | 489 if (it == portal_state_map_.end() || it->second.status != state.status || |
| 491 it->second.response_code != state.response_code) { | 490 it->second.response_code != state.response_code) { |
| 492 VLOG(1) << "Updating Chrome Captive Portal state: " | 491 VLOG(1) << "Updating Chrome Captive Portal state: " |
| 493 << "name=" << network->name() << ", " | 492 << "name=" << network->name() << ", " |
| 494 << "id=" << network->guid() << ", " | 493 << "id=" << network->guid() << ", status=" |
| 495 << "status=" << CaptivePortalStatusString(state.status) << ", " | 494 << captive_portal::CaptivePortalStatusString(state.status) |
| 496 << "response_code=" << state.response_code; | 495 << ", response_code=" << state.response_code; |
| 497 | 496 |
| 498 // Record detection duration iff detection result differs from the | 497 // Record detection duration iff detection result differs from the |
| 499 // previous one for this network. The reason is to record all stats | 498 // previous one for this network. The reason is to record all stats |
| 500 // only when network changes it's state. | 499 // only when network changes it's state. |
| 501 RecordDetectionStats(network, state.status); | 500 RecordDetectionStats(network, state.status); |
| 502 if (it != portal_state_map_.end() && | 501 if (it != portal_state_map_.end() && |
| 503 it->second.status == CAPTIVE_PORTAL_STATUS_PORTAL && | 502 it->second.status == captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL && |
| 504 state.status == CAPTIVE_PORTAL_STATUS_ONLINE) { | 503 state.status == captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE) { |
| 505 RecordPortalToOnlineTransition(state.time - it->second.time); | 504 RecordPortalToOnlineTransition(state.time - it->second.time); |
| 506 } | 505 } |
| 507 | 506 |
| 508 portal_state_map_[network->path()] = state; | 507 portal_state_map_[network->path()] = state; |
| 509 } | 508 } |
| 510 NotifyDetectionCompleted(network, state); | 509 NotifyDetectionCompleted(network, state); |
| 511 } | 510 } |
| 512 | 511 |
| 513 void NetworkPortalDetectorImpl::NotifyDetectionCompleted( | 512 void NetworkPortalDetectorImpl::NotifyDetectionCompleted( |
| 514 const NetworkState* network, | 513 const NetworkState* network, |
| 515 const CaptivePortalState& state) { | 514 const CaptivePortalState& state) { |
| 516 FOR_EACH_OBSERVER( | 515 FOR_EACH_OBSERVER( |
| 517 Observer, observers_, OnPortalDetectionCompleted(network, state)); | 516 Observer, observers_, OnPortalDetectionCompleted(network, state)); |
| 518 notification_controller_.OnPortalDetectionCompleted(network, state); | 517 notification_controller_.OnPortalDetectionCompleted(network, state); |
| 519 } | 518 } |
| 520 | 519 |
| 521 bool NetworkPortalDetectorImpl::AttemptTimeoutIsCancelledForTesting() const { | 520 bool NetworkPortalDetectorImpl::AttemptTimeoutIsCancelledForTesting() const { |
| 522 return attempt_timeout_.IsCancelled(); | 521 return attempt_timeout_.IsCancelled(); |
| 523 } | 522 } |
| 524 | 523 |
| 525 void NetworkPortalDetectorImpl::RecordDetectionStats( | 524 void NetworkPortalDetectorImpl::RecordDetectionStats( |
| 526 const NetworkState* network, | 525 const NetworkState* network, |
| 527 CaptivePortalStatus status) { | 526 captive_portal::CaptivePortalStatus status) { |
| 528 // Don't record stats for offline state. | 527 // Don't record stats for offline state. |
| 529 if (!network) | 528 if (!network) |
| 530 return; | 529 return; |
| 531 | 530 |
| 532 if (!detection_start_time_.is_null()) | 531 if (!detection_start_time_.is_null()) |
| 533 RecordDetectionDuration(GetCurrentTimeTicks() - detection_start_time_); | 532 RecordDetectionDuration(GetCurrentTimeTicks() - detection_start_time_); |
| 534 RecordDetectionResult(status); | 533 RecordDetectionResult(status); |
| 535 | 534 |
| 536 switch (status) { | 535 switch (status) { |
| 537 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | 536 case captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
| 538 NOTREACHED(); | 537 NOTREACHED(); |
| 539 break; | 538 break; |
| 540 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: | 539 case captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE: |
| 541 if (network->connection_state() == shill::kStateOnline || | 540 if (network->connection_state() == shill::kStateOnline || |
| 542 network->connection_state() == shill::kStatePortal) { | 541 network->connection_state() == shill::kStatePortal) { |
| 543 RecordDiscrepancyWithShill(network, status); | 542 RecordDiscrepancyWithShill(network, status); |
| 544 } | 543 } |
| 545 break; | 544 break; |
| 546 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | 545 case captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE: |
| 547 if (network->connection_state() != shill::kStateOnline) | 546 if (network->connection_state() != shill::kStateOnline) |
| 548 RecordDiscrepancyWithShill(network, status); | 547 RecordDiscrepancyWithShill(network, status); |
| 549 break; | 548 break; |
| 550 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: | 549 case captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL: |
| 551 if (network->connection_state() != shill::kStatePortal) | 550 if (network->connection_state() != shill::kStatePortal) |
| 552 RecordDiscrepancyWithShill(network, status); | 551 RecordDiscrepancyWithShill(network, status); |
| 553 break; | 552 break; |
| 554 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | 553 case captive_portal::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
| 555 if (network->connection_state() != shill::kStateOnline) | 554 if (network->connection_state() != shill::kStateOnline) |
| 556 RecordDiscrepancyWithShill(network, status); | 555 RecordDiscrepancyWithShill(network, status); |
| 557 break; | 556 break; |
| 558 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: | 557 case captive_portal::CAPTIVE_PORTAL_STATUS_COUNT: |
| 559 NOTREACHED(); | 558 NOTREACHED(); |
| 560 break; | 559 break; |
| 561 } | 560 } |
| 562 } | 561 } |
| 563 | 562 |
| 564 void NetworkPortalDetectorImpl::UpdateCurrentStrategy() { | 563 void NetworkPortalDetectorImpl::UpdateCurrentStrategy() { |
| 565 if (InSession()) { | 564 if (InSession()) { |
| 566 SetStrategy(PortalDetectorStrategy::STRATEGY_ID_SESSION); | 565 SetStrategy(PortalDetectorStrategy::STRATEGY_ID_SESSION); |
| 567 return; | 566 return; |
| 568 } | 567 } |
| 569 if (error_screen_displayed_) { | 568 if (error_screen_displayed_) { |
| 570 SetStrategy(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); | 569 SetStrategy(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); |
| 571 return; | 570 return; |
| 572 } | 571 } |
| 573 SetStrategy(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); | 572 SetStrategy(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); |
| 574 } | 573 } |
| 575 | 574 |
| 576 void NetworkPortalDetectorImpl::SetStrategy( | 575 void NetworkPortalDetectorImpl::SetStrategy( |
| 577 PortalDetectorStrategy::StrategyId id) { | 576 PortalDetectorStrategy::StrategyId id) { |
| 578 if (id == strategy_->Id()) | 577 if (id == strategy_->Id()) |
| 579 return; | 578 return; |
| 580 strategy_.reset(PortalDetectorStrategy::CreateById(id).release()); | 579 strategy_.reset(PortalDetectorStrategy::CreateById(id).release()); |
| 581 strategy_->set_delegate(this); | 580 strategy_->set_delegate(this); |
| 582 StopDetection(); | 581 StopDetection(); |
| 583 StartDetectionIfIdle(); | 582 StartDetectionIfIdle(); |
| 584 } | 583 } |
| 585 | 584 |
| 586 } // namespace chromeos | 585 } // namespace chromeos |
| OLD | NEW |