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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 static const char kSessionShillOnlineHistogram[]; | 58 static const char kSessionShillOnlineHistogram[]; |
59 static const char kSessionShillPortalHistogram[]; | 59 static const char kSessionShillPortalHistogram[]; |
60 static const char kSessionShillOfflineHistogram[]; | 60 static const char kSessionShillOfflineHistogram[]; |
61 static const char kSessionPortalToOnlineHistogram[]; | 61 static const char kSessionPortalToOnlineHistogram[]; |
62 | 62 |
63 // Creates an instance of NetworkPortalDetectorImpl. | 63 // Creates an instance of NetworkPortalDetectorImpl. |
64 static void Initialize(net::URLRequestContextGetter* url_context); | 64 static void Initialize(net::URLRequestContextGetter* url_context); |
65 | 65 |
66 explicit NetworkPortalDetectorImpl( | 66 explicit NetworkPortalDetectorImpl( |
67 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 67 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
68 virtual ~NetworkPortalDetectorImpl(); | 68 ~NetworkPortalDetectorImpl() override; |
69 | 69 |
70 // NetworkPortalDetector implementation: | 70 // NetworkPortalDetector implementation: |
71 virtual void AddObserver(Observer* observer) override; | 71 void AddObserver(Observer* observer) override; |
72 virtual void AddAndFireObserver(Observer* observer) override; | 72 void AddAndFireObserver(Observer* observer) override; |
73 virtual void RemoveObserver(Observer* observer) override; | 73 void RemoveObserver(Observer* observer) override; |
74 virtual CaptivePortalState GetCaptivePortalState( | 74 CaptivePortalState GetCaptivePortalState(const std::string& guid) override; |
75 const std::string& guid) override; | 75 bool IsEnabled() override; |
76 virtual bool IsEnabled() override; | 76 void Enable(bool start_detection) override; |
77 virtual void Enable(bool start_detection) override; | 77 bool StartDetectionIfIdle() override; |
78 virtual bool StartDetectionIfIdle() override; | 78 void SetStrategy(PortalDetectorStrategy::StrategyId id) override; |
79 virtual void SetStrategy(PortalDetectorStrategy::StrategyId id) override; | |
80 | 79 |
81 // NetworkStateHandlerObserver implementation: | 80 // NetworkStateHandlerObserver implementation: |
82 virtual void DefaultNetworkChanged(const NetworkState* network) override; | 81 void DefaultNetworkChanged(const NetworkState* network) override; |
83 | 82 |
84 // PortalDetectorStrategy::Delegate implementation: | 83 // PortalDetectorStrategy::Delegate implementation: |
85 virtual int NoResponseResultCount() override; | 84 int NoResponseResultCount() override; |
86 virtual base::TimeTicks AttemptStartTime() override; | 85 base::TimeTicks AttemptStartTime() override; |
87 virtual base::TimeTicks GetCurrentTimeTicks() override; | 86 base::TimeTicks GetCurrentTimeTicks() override; |
88 | 87 |
89 private: | 88 private: |
90 friend class NetworkPortalDetectorImplTest; | 89 friend class NetworkPortalDetectorImplTest; |
91 friend class NetworkPortalDetectorImplBrowserTest; | 90 friend class NetworkPortalDetectorImplBrowserTest; |
92 | 91 |
93 struct DetectionAttemptCompletedReport { | 92 struct DetectionAttemptCompletedReport { |
94 DetectionAttemptCompletedReport(); | 93 DetectionAttemptCompletedReport(); |
95 | 94 |
96 DetectionAttemptCompletedReport(const std::string network_name, | 95 DetectionAttemptCompletedReport(const std::string network_name, |
97 const std::string network_id, | 96 const std::string network_id, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 133 |
135 // Called when portal check is timed out. Cancels portal check and calls | 134 // Called when portal check is timed out. Cancels portal check and calls |
136 // OnPortalDetectionCompleted() with RESULT_NO_RESPONSE as a result. | 135 // OnPortalDetectionCompleted() with RESULT_NO_RESPONSE as a result. |
137 void OnAttemptTimeout(); | 136 void OnAttemptTimeout(); |
138 | 137 |
139 // Called by CaptivePortalDetector when detection attempt completes. | 138 // Called by CaptivePortalDetector when detection attempt completes. |
140 void OnAttemptCompleted( | 139 void OnAttemptCompleted( |
141 const captive_portal::CaptivePortalDetector::Results& results); | 140 const captive_portal::CaptivePortalDetector::Results& results); |
142 | 141 |
143 // content::NotificationObserver implementation: | 142 // content::NotificationObserver implementation: |
144 virtual void Observe(int type, | 143 void Observe(int type, |
145 const content::NotificationSource& source, | 144 const content::NotificationSource& source, |
146 const content::NotificationDetails& details) override; | 145 const content::NotificationDetails& details) override; |
147 | 146 |
148 // Stores captive portal state for a |network| and notifies observers. | 147 // Stores captive portal state for a |network| and notifies observers. |
149 void OnDetectionCompleted(const NetworkState* network, | 148 void OnDetectionCompleted(const NetworkState* network, |
150 const CaptivePortalState& results); | 149 const CaptivePortalState& results); |
151 | 150 |
152 // Notifies observers that portal detection is completed for a |network|. | 151 // Notifies observers that portal detection is completed for a |network|. |
153 void NotifyDetectionCompleted(const NetworkState* network, | 152 void NotifyDetectionCompleted(const NetworkState* network, |
154 const CaptivePortalState& state); | 153 const CaptivePortalState& state); |
155 | 154 |
156 State state() const { return state_; } | 155 State state() const { return state_; } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 DetectionAttemptCompletedReport attempt_completed_report_; | 262 DetectionAttemptCompletedReport attempt_completed_report_; |
264 | 263 |
265 base::WeakPtrFactory<NetworkPortalDetectorImpl> weak_factory_; | 264 base::WeakPtrFactory<NetworkPortalDetectorImpl> weak_factory_; |
266 | 265 |
267 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); | 266 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); |
268 }; | 267 }; |
269 | 268 |
270 } // namespace chromeos | 269 } // namespace chromeos |
271 | 270 |
272 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 271 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
OLD | NEW |