| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 void NetworkPortalDetectorImpl::DisableLazyDetection() { | 200 void NetworkPortalDetectorImpl::DisableLazyDetection() { |
| 201 if (!lazy_detection_enabled()) | 201 if (!lazy_detection_enabled()) |
| 202 return; | 202 return; |
| 203 lazy_detection_enabled_ = false; | 203 lazy_detection_enabled_ = false; |
| 204 if (attempt_count_ == kMaxRequestAttempts && IsPortalCheckPending()) | 204 if (attempt_count_ == kMaxRequestAttempts && IsPortalCheckPending()) |
| 205 CancelPortalDetection(); | 205 CancelPortalDetection(); |
| 206 VLOG(1) << "Lazy detection mode disabled."; | 206 VLOG(1) << "Lazy detection mode disabled."; |
| 207 } | 207 } |
| 208 | 208 |
| 209 void NetworkPortalDetectorImpl::NetworkManagerChanged() { | 209 void NetworkPortalDetectorImpl::DefaultNetworkChanged( |
| 210 const NetworkState* default_network) { |
| 210 DCHECK(CalledOnValidThread()); | 211 DCHECK(CalledOnValidThread()); |
| 211 const NetworkState* default_network = | |
| 212 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); | |
| 213 if (!default_network) { | 212 if (!default_network) { |
| 214 default_network_id_.clear(); | 213 default_network_id_.clear(); |
| 215 return; | 214 return; |
| 216 } | 215 } |
| 217 | 216 |
| 218 default_network_id_ = default_network->guid(); | 217 default_network_id_ = default_network->guid(); |
| 219 | 218 |
| 220 bool network_changed = (default_service_path_ != default_network->path()); | 219 bool network_changed = (default_service_path_ != default_network->path()); |
| 221 default_service_path_ = default_network->path(); | 220 default_service_path_ = default_network->path(); |
| 222 | 221 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 236 // offline or if network connection state was changed. | 235 // offline or if network connection state was changed. |
| 237 CaptivePortalState state = GetCaptivePortalState(default_network); | 236 CaptivePortalState state = GetCaptivePortalState(default_network); |
| 238 if (state.status == CAPTIVE_PORTAL_STATUS_UNKNOWN || | 237 if (state.status == CAPTIVE_PORTAL_STATUS_UNKNOWN || |
| 239 state.status == CAPTIVE_PORTAL_STATUS_OFFLINE || | 238 state.status == CAPTIVE_PORTAL_STATUS_OFFLINE || |
| 240 (!network_changed && connection_state_changed)) { | 239 (!network_changed && connection_state_changed)) { |
| 241 DetectCaptivePortal(base::TimeDelta()); | 240 DetectCaptivePortal(base::TimeDelta()); |
| 242 } | 241 } |
| 243 } | 242 } |
| 244 } | 243 } |
| 245 | 244 |
| 246 void NetworkPortalDetectorImpl::DefaultNetworkChanged( | |
| 247 const NetworkState* network) { | |
| 248 NetworkManagerChanged(); | |
| 249 } | |
| 250 | |
| 251 //////////////////////////////////////////////////////////////////////////////// | 245 //////////////////////////////////////////////////////////////////////////////// |
| 252 // NetworkPortalDetectorImpl, private: | 246 // NetworkPortalDetectorImpl, private: |
| 253 | 247 |
| 254 bool NetworkPortalDetectorImpl::CanPerformDetection() const { | 248 bool NetworkPortalDetectorImpl::CanPerformDetection() const { |
| 255 if (IsPortalCheckPending() || IsCheckingForPortal()) | 249 if (IsPortalCheckPending() || IsCheckingForPortal()) |
| 256 return false; | 250 return false; |
| 257 return attempt_count_ < kMaxRequestAttempts || lazy_detection_enabled(); | 251 return attempt_count_ < kMaxRequestAttempts || lazy_detection_enabled(); |
| 258 } | 252 } |
| 259 | 253 |
| 260 void NetworkPortalDetectorImpl::DetectCaptivePortal( | 254 void NetworkPortalDetectorImpl::DetectCaptivePortal( |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 const NetworkState* network = | 489 const NetworkState* network = |
| 496 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); | 490 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
| 497 if (!network) | 491 if (!network) |
| 498 return kBaseRequestTimeoutSec; | 492 return kBaseRequestTimeoutSec; |
| 499 if (lazy_detection_enabled_) | 493 if (lazy_detection_enabled_) |
| 500 return kLazyRequestTimeoutSec; | 494 return kLazyRequestTimeoutSec; |
| 501 return attempt_count_ * kBaseRequestTimeoutSec; | 495 return attempt_count_ * kBaseRequestTimeoutSec; |
| 502 } | 496 } |
| 503 | 497 |
| 504 } // namespace chromeos | 498 } // namespace chromeos |
| OLD | NEW |