| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/sequence_checker.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "chromeos/network/network_state_handler_observer.h" | 20 #include "chromeos/network/network_state_handler_observer.h" |
| 21 #include "chromeos/network/portal_detector/network_portal_detector.h" | 21 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 22 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" | 22 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" |
| 23 #include "components/captive_portal/captive_portal_detector.h" | 23 #include "components/captive_portal/captive_portal_detector.h" |
| 24 #include "components/captive_portal/captive_portal_types.h" | 24 #include "components/captive_portal/captive_portal_types.h" |
| 25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "net/url_request/url_fetcher.h" | 27 #include "net/url_request/url_fetcher.h" |
| 28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 | 29 |
| 30 class NetworkingConfigTest; | 30 class NetworkingConfigTest; |
| 31 | 31 |
| 32 namespace net { | 32 namespace net { |
| 33 class URLRequestContextGetter; | 33 class URLRequestContextGetter; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace chromeos { | 36 namespace chromeos { |
| 37 | 37 |
| 38 class NetworkPortalNotificationController; | 38 class NetworkPortalNotificationController; |
| 39 class NetworkState; | 39 class NetworkState; |
| 40 | 40 |
| 41 // This class handles all notifications about network changes from | 41 // This class handles all notifications about network changes from |
| 42 // NetworkStateHandler and delegates portal detection for the default | 42 // NetworkStateHandler and delegates portal detection for the default |
| 43 // network to CaptivePortalService. | 43 // network to CaptivePortalService. |
| 44 class NetworkPortalDetectorImpl : public NetworkPortalDetector, | 44 class NetworkPortalDetectorImpl : public NetworkPortalDetector, |
| 45 public base::NonThreadSafe, | |
| 46 public chromeos::NetworkStateHandlerObserver, | 45 public chromeos::NetworkStateHandlerObserver, |
| 47 public content::NotificationObserver, | 46 public content::NotificationObserver, |
| 48 public PortalDetectorStrategy::Delegate { | 47 public PortalDetectorStrategy::Delegate { |
| 49 public: | 48 public: |
| 50 static const char kOobeDetectionResultHistogram[]; | 49 static const char kOobeDetectionResultHistogram[]; |
| 51 static const char kOobeDetectionDurationHistogram[]; | 50 static const char kOobeDetectionDurationHistogram[]; |
| 52 static const char kOobeShillOnlineHistogram[]; | 51 static const char kOobeShillOnlineHistogram[]; |
| 53 static const char kOobeShillPortalHistogram[]; | 52 static const char kOobeShillPortalHistogram[]; |
| 54 static const char kOobeShillOfflineHistogram[]; | 53 static const char kOobeShillOfflineHistogram[]; |
| 55 static const char kOobePortalToOnlineHistogram[]; | 54 static const char kOobePortalToOnlineHistogram[]; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 251 |
| 253 // Last received result from captive portal detector. | 252 // Last received result from captive portal detector. |
| 254 CaptivePortalStatus last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; | 253 CaptivePortalStatus last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; |
| 255 | 254 |
| 256 // Number of detection attempts with same result in a row. | 255 // Number of detection attempts with same result in a row. |
| 257 int same_detection_result_count_ = 0; | 256 int same_detection_result_count_ = 0; |
| 258 | 257 |
| 259 // Number of detection attempts in a row with NO RESPONSE result. | 258 // Number of detection attempts in a row with NO RESPONSE result. |
| 260 int no_response_result_count_ = 0; | 259 int no_response_result_count_ = 0; |
| 261 | 260 |
| 261 // Must be declared before |notification_controller_| as |
| 262 // ~NetworkPortalNotificationController() calls |
| 263 // NetworkPortalDetectorImpl::RemoveObserver() which uses this. |
| 264 SEQUENCE_CHECKER(sequence_checker_); |
| 265 |
| 262 // UI notification controller about captive portal state. | 266 // UI notification controller about captive portal state. |
| 263 std::unique_ptr<NetworkPortalNotificationController> notification_controller_; | 267 std::unique_ptr<NetworkPortalNotificationController> notification_controller_; |
| 264 | 268 |
| 265 content::NotificationRegistrar registrar_; | 269 content::NotificationRegistrar registrar_; |
| 266 | 270 |
| 267 // Test time ticks used by unit tests. | 271 // Test time ticks used by unit tests. |
| 268 base::TimeTicks time_ticks_for_testing_; | 272 base::TimeTicks time_ticks_for_testing_; |
| 269 | 273 |
| 270 // Contents of a last log message about completed detection attempt. | 274 // Contents of a last log message about completed detection attempt. |
| 271 DetectionAttemptCompletedReport attempt_completed_report_; | 275 DetectionAttemptCompletedReport attempt_completed_report_; |
| 272 | 276 |
| 273 base::WeakPtrFactory<NetworkPortalDetectorImpl> weak_factory_; | 277 base::WeakPtrFactory<NetworkPortalDetectorImpl> weak_factory_; |
| 274 | 278 |
| 275 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); | 279 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); |
| 276 }; | 280 }; |
| 277 | 281 |
| 278 } // namespace chromeos | 282 } // namespace chromeos |
| 279 | 283 |
| 280 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 284 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| OLD | NEW |