| 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 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // This class handles all notifications about network changes from | 36 // This class handles all notifications about network changes from |
| 37 // NetworkStateHandler and delegates portal detection for the default | 37 // NetworkStateHandler and delegates portal detection for the default |
| 38 // network to CaptivePortalService. | 38 // network to CaptivePortalService. |
| 39 class NetworkPortalDetectorImpl | 39 class NetworkPortalDetectorImpl |
| 40 : public NetworkPortalDetector, | 40 : public NetworkPortalDetector, |
| 41 public base::NonThreadSafe, | 41 public base::NonThreadSafe, |
| 42 public chromeos::NetworkStateHandlerObserver, | 42 public chromeos::NetworkStateHandlerObserver, |
| 43 public content::NotificationObserver { | 43 public content::NotificationObserver { |
| 44 public: | 44 public: |
| 45 static const char kDetectionResultHistogram[]; |
| 46 static const char kDetectionDurationHistogram[]; |
| 47 static const char kShillOnlineHistogram[]; |
| 48 static const char kShillPortalHistogram[]; |
| 49 static const char kShillOfflineHistogram[]; |
| 50 |
| 45 explicit NetworkPortalDetectorImpl( | 51 explicit NetworkPortalDetectorImpl( |
| 46 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 52 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
| 47 virtual ~NetworkPortalDetectorImpl(); | 53 virtual ~NetworkPortalDetectorImpl(); |
| 48 | 54 |
| 49 // NetworkPortalDetector implementation: | 55 // NetworkPortalDetector implementation: |
| 50 virtual void AddObserver(Observer* observer) OVERRIDE; | 56 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 51 virtual void AddAndFireObserver(Observer* observer) OVERRIDE; | 57 virtual void AddAndFireObserver(Observer* observer) OVERRIDE; |
| 52 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 58 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 53 virtual CaptivePortalState GetCaptivePortalState( | 59 virtual CaptivePortalState GetCaptivePortalState( |
| 54 const chromeos::NetworkState* network) OVERRIDE; | 60 const chromeos::NetworkState* network) OVERRIDE; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // cancelled. | 186 // cancelled. |
| 181 bool DetectionTimeoutIsCancelledForTesting() const; | 187 bool DetectionTimeoutIsCancelledForTesting() const; |
| 182 | 188 |
| 183 // Returns timeout for current (or immediate) detection attempt. | 189 // Returns timeout for current (or immediate) detection attempt. |
| 184 // The following rules are used for timeout computation: | 190 // The following rules are used for timeout computation: |
| 185 // * if default (active) network is NULL, kBaseRequestTimeoutSec is used | 191 // * if default (active) network is NULL, kBaseRequestTimeoutSec is used |
| 186 // * if lazy detection mode is enabled, kLazyRequestTimeoutSec is used | 192 // * if lazy detection mode is enabled, kLazyRequestTimeoutSec is used |
| 187 // * otherwise, timeout equals to |attempt_count_| * kBaseRequestTimeoutSec | 193 // * otherwise, timeout equals to |attempt_count_| * kBaseRequestTimeoutSec |
| 188 int GetRequestTimeoutSec() const; | 194 int GetRequestTimeoutSec() const; |
| 189 | 195 |
| 196 // Record detection stats such as detection duration and detection |
| 197 // result in UMA. |
| 198 void RecordDetectionStats(const NetworkState* network, |
| 199 CaptivePortalStatus status); |
| 200 |
| 190 // Name of the default network. | 201 // Name of the default network. |
| 191 std::string default_network_name_; | 202 std::string default_network_name_; |
| 192 | 203 |
| 193 // Unique identifier of the default network. | 204 // Unique identifier of the default network. |
| 194 std::string default_network_id_; | 205 std::string default_network_id_; |
| 195 | 206 |
| 196 // Service path of the default network. | 207 // Service path of the default network. |
| 197 std::string default_service_path_; | 208 std::string default_service_path_; |
| 198 | 209 |
| 199 // Connection state of the default network. | 210 // Connection state of the default network. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 bool request_timeout_for_testing_initialized_; | 260 bool request_timeout_for_testing_initialized_; |
| 250 | 261 |
| 251 content::NotificationRegistrar registrar_; | 262 content::NotificationRegistrar registrar_; |
| 252 | 263 |
| 253 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); | 264 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); |
| 254 }; | 265 }; |
| 255 | 266 |
| 256 } // namespace chromeos | 267 } // namespace chromeos |
| 257 | 268 |
| 258 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 269 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| OLD | NEW |