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 <string> | 9 #include <string> |
9 | 10 |
10 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.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/threading/non_thread_safe.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" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 CaptivePortalStateMap portal_state_map_; | 225 CaptivePortalStateMap portal_state_map_; |
226 base::ObserverList<Observer> observers_; | 226 base::ObserverList<Observer> observers_; |
227 | 227 |
228 base::CancelableClosure attempt_task_; | 228 base::CancelableClosure attempt_task_; |
229 base::CancelableClosure attempt_timeout_; | 229 base::CancelableClosure attempt_timeout_; |
230 | 230 |
231 // URL that returns a 204 response code when connected to the Internet. | 231 // URL that returns a 204 response code when connected to the Internet. |
232 GURL portal_test_url_; | 232 GURL portal_test_url_; |
233 | 233 |
234 // Detector for checking default network for a portal state. | 234 // Detector for checking default network for a portal state. |
235 scoped_ptr<captive_portal::CaptivePortalDetector> captive_portal_detector_; | 235 std::unique_ptr<captive_portal::CaptivePortalDetector> |
| 236 captive_portal_detector_; |
236 | 237 |
237 // True if the NetworkPortalDetector is enabled. | 238 // True if the NetworkPortalDetector is enabled. |
238 bool enabled_ = false; | 239 bool enabled_ = false; |
239 | 240 |
240 // Start time of portal detection. | 241 // Start time of portal detection. |
241 base::TimeTicks detection_start_time_; | 242 base::TimeTicks detection_start_time_; |
242 | 243 |
243 // Start time of detection attempt. | 244 // Start time of detection attempt. |
244 base::TimeTicks attempt_start_time_; | 245 base::TimeTicks attempt_start_time_; |
245 | 246 |
246 // Delay before next portal detection. | 247 // Delay before next portal detection. |
247 base::TimeDelta next_attempt_delay_; | 248 base::TimeDelta next_attempt_delay_; |
248 | 249 |
249 // Current detection strategy. | 250 // Current detection strategy. |
250 scoped_ptr<PortalDetectorStrategy> strategy_; | 251 std::unique_ptr<PortalDetectorStrategy> strategy_; |
251 | 252 |
252 // Last received result from captive portal detector. | 253 // Last received result from captive portal detector. |
253 CaptivePortalStatus last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; | 254 CaptivePortalStatus last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; |
254 | 255 |
255 // Number of detection attempts with same result in a row. | 256 // Number of detection attempts with same result in a row. |
256 int same_detection_result_count_ = 0; | 257 int same_detection_result_count_ = 0; |
257 | 258 |
258 // Number of detection attempts in a row with NO RESPONSE result. | 259 // Number of detection attempts in a row with NO RESPONSE result. |
259 int no_response_result_count_ = 0; | 260 int no_response_result_count_ = 0; |
260 | 261 |
261 // UI notification controller about captive portal state. | 262 // UI notification controller about captive portal state. |
262 scoped_ptr<NetworkPortalNotificationController> notification_controller_; | 263 std::unique_ptr<NetworkPortalNotificationController> notification_controller_; |
263 | 264 |
264 content::NotificationRegistrar registrar_; | 265 content::NotificationRegistrar registrar_; |
265 | 266 |
266 // Test time ticks used by unit tests. | 267 // Test time ticks used by unit tests. |
267 base::TimeTicks time_ticks_for_testing_; | 268 base::TimeTicks time_ticks_for_testing_; |
268 | 269 |
269 // Contents of a last log message about completed detection attempt. | 270 // Contents of a last log message about completed detection attempt. |
270 DetectionAttemptCompletedReport attempt_completed_report_; | 271 DetectionAttemptCompletedReport attempt_completed_report_; |
271 | 272 |
272 base::WeakPtrFactory<NetworkPortalDetectorImpl> weak_factory_; | 273 base::WeakPtrFactory<NetworkPortalDetectorImpl> weak_factory_; |
273 | 274 |
274 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); | 275 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); |
275 }; | 276 }; |
276 | 277 |
277 } // namespace chromeos | 278 } // namespace chromeos |
278 | 279 |
279 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 280 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
OLD | NEW |