Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9651)

Unified Diff: chrome/browser/chromeos/net/network_portal_detector.h

Issue 12260003: Implemented lazy portal detection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/net/network_portal_detector.h
diff --git a/chrome/browser/chromeos/net/network_portal_detector.h b/chrome/browser/chromeos/net/network_portal_detector.h
index 1c68a0ad83ad5a1b7c225c4568a24df741b61518..d052128750f0645b46c4b804f9ca35ec88a0c02a 100644
--- a/chrome/browser/chromeos/net/network_portal_detector.h
+++ b/chrome/browser/chromeos/net/network_portal_detector.h
@@ -86,6 +86,13 @@ class NetworkPortalDetector
virtual void OnNetworkChanged(chromeos::NetworkLibrary* cros,
const chromeos::Network* network) OVERRIDE;
+ // Enables lazy detection mode. In this mode portal detection after
+ // first 3 consecutive attemps will be performed once in 30 seconds.
+ void EnableLazyDetection();
+
+ // Dizables lazy detection mode.
+ void DisableLazyDetection();
+
// Creates an instance of the NetworkPortalDetector.
static NetworkPortalDetector* CreateInstance();
@@ -129,6 +136,10 @@ class NetworkPortalDetector
void OnPortalDetectionCompleted(
const captive_portal::CaptivePortalDetector::Results& results);
+ // Tries to perform portal detection in "lazy" mode. Does nothing in
+ // the case of already pending/processing detection request.
+ void TryLazyDetection();
+
// content::NotificationObserver implementation:
virtual void Observe(int type,
const content::NotificationSource& source,
@@ -163,6 +174,12 @@ class NetworkPortalDetector
min_time_between_attempts_ = delta;
}
+ // Sets default interval between consecutive portal checks for a
+ // network in portal state. Used by unit tests.
+ void set_lazy_check_interval_for_testing(const base::TimeDelta& delta) {
+ lazy_check_interval_ = delta;
+ }
+
// Sets portal detection timeout. Used by unit tests.
void set_request_timeout_for_testing(const base::TimeDelta& timeout) {
request_timeout_ = timeout;
@@ -210,6 +227,13 @@ class NetworkPortalDetector
// Number of portal detection attemps for an active network.
int attempt_count_;
+ // True if lazy detection is enabled.
+ bool lazy_detection_enabled_;
+
+ // Time between consecutive portal checks for a network in lazy
+ // mode.
+ base::TimeDelta lazy_check_interval_;
+
// Minimum time between consecutive portal checks for the same
// active network.
base::TimeDelta min_time_between_attempts_;

Powered by Google App Engine
This is Rietveld 408576698