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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 if (result == captive_portal::RESULT_NO_RESPONSE) | 543 if (result == captive_portal::RESULT_NO_RESPONSE) |
544 ++no_response_result_count_; | 544 ++no_response_result_count_; |
545 else | 545 else |
546 no_response_result_count_ = 0; | 546 no_response_result_count_ = 0; |
547 | 547 |
548 if (state.status != CAPTIVE_PORTAL_STATUS_OFFLINE || | 548 if (state.status != CAPTIVE_PORTAL_STATUS_OFFLINE || |
549 same_detection_result_count_ >= kMaxOfflineResultsBeforeReport) { | 549 same_detection_result_count_ >= kMaxOfflineResultsBeforeReport) { |
550 OnDetectionCompleted(network, state); | 550 OnDetectionCompleted(network, state); |
551 } | 551 } |
552 | 552 |
553 // Observers (via OnDetectionCompleted) may already schedule new attempt. | 553 // Do not schedule attempt if (1) Observers (via OnDetectionCompleted) has |
554 if (is_idle()) | 554 // already scheduled a new attempt or (2) we are behind a captive portal with |
555 // response code 200, which can be either the result of NetworkPortalDetector | |
556 // or shill's detection. | |
557 if (is_idle() && | |
558 (state.status != CAPTIVE_PORTAL_STATUS_PORTAL || response_code != 200)) { | |
555 ScheduleAttempt(results.retry_after_delta); | 559 ScheduleAttempt(results.retry_after_delta); |
560 } | |
stevenjb
2017/03/17 16:53:01
This logic got a bit complicated, let's break it u
Qiang(Joe) Xu
2017/03/17 17:23:55
agree. Done, thanks!
| |
556 } | 561 } |
557 | 562 |
558 void NetworkPortalDetectorImpl::Observe( | 563 void NetworkPortalDetectorImpl::Observe( |
559 int type, | 564 int type, |
560 const content::NotificationSource& source, | 565 const content::NotificationSource& source, |
561 const content::NotificationDetails& details) { | 566 const content::NotificationDetails& details) { |
562 if (type == chrome::NOTIFICATION_LOGIN_PROXY_CHANGED || | 567 if (type == chrome::NOTIFICATION_LOGIN_PROXY_CHANGED || |
563 type == chrome::NOTIFICATION_AUTH_SUPPLIED || | 568 type == chrome::NOTIFICATION_AUTH_SUPPLIED || |
564 type == chrome::NOTIFICATION_AUTH_CANCELLED) { | 569 type == chrome::NOTIFICATION_AUTH_CANCELLED) { |
565 NET_LOG(EVENT) << "Restarting portal detection due to proxy change" | 570 NET_LOG(EVENT) << "Restarting portal detection due to proxy change" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 } | 650 } |
646 | 651 |
647 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() { | 652 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() { |
648 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; | 653 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; |
649 same_detection_result_count_ = 0; | 654 same_detection_result_count_ = 0; |
650 no_response_result_count_ = 0; | 655 no_response_result_count_ = 0; |
651 strategy_->Reset(); | 656 strategy_->Reset(); |
652 } | 657 } |
653 | 658 |
654 } // namespace chromeos | 659 } // namespace chromeos |
OLD | NEW |