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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_detector_impl.cc

Issue 1353933002: NetworkPortalDetectorInterface class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@portal_refactor
Patch Set: rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" 5 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 UMA_HISTOGRAM_LONG_TIMES( 134 UMA_HISTOGRAM_LONG_TIMES(
135 NetworkPortalDetectorImpl::kSessionPortalToOnlineHistogram, 135 NetworkPortalDetectorImpl::kSessionPortalToOnlineHistogram,
136 duration); 136 duration);
137 } else { 137 } else {
138 UMA_HISTOGRAM_LONG_TIMES( 138 UMA_HISTOGRAM_LONG_TIMES(
139 NetworkPortalDetectorImpl::kOobePortalToOnlineHistogram, 139 NetworkPortalDetectorImpl::kOobePortalToOnlineHistogram,
140 duration); 140 duration);
141 } 141 }
142 } 142 }
143 143
144 class NetworkPortalDetectorStubImpl : public NetworkPortalDetectorInterface {
145 public:
146 NetworkPortalDetectorStubImpl() {}
147 ~NetworkPortalDetectorStubImpl() override {}
148
149 private:
150 // NetworkPortalDetector:
151 void AddObserver(Observer* observer) override {}
152 void AddAndFireObserver(Observer* observer) override {
153 if (observer)
154 observer->OnPortalDetectionCompleted(nullptr, CaptivePortalState());
155 }
156 void RemoveObserver(Observer* observer) override {}
157 CaptivePortalState GetCaptivePortalState(
158 const std::string& service_path) override {
159 return CaptivePortalState();
160 }
161 bool IsEnabled() override { return false; }
162 void Enable(bool start_detection) override {}
163 bool StartDetectionIfIdle() override { return false; }
164 void SetStrategy(PortalDetectorStrategy::StrategyId id) override {}
165 void OnLockScreenRequest() override {}
166
167 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorStubImpl);
168 };
169
144 } // namespace 170 } // namespace
145 171
146 //////////////////////////////////////////////////////////////////////////////// 172 ////////////////////////////////////////////////////////////////////////////////
147 // NetworkPortalDetectorImpl::DetectionAttemptCompletedLogState 173 // NetworkPortalDetectorImpl::DetectionAttemptCompletedLogState
148 174
149 NetworkPortalDetectorImpl::DetectionAttemptCompletedReport:: 175 NetworkPortalDetectorImpl::DetectionAttemptCompletedReport::
150 DetectionAttemptCompletedReport() 176 DetectionAttemptCompletedReport()
151 : result(captive_portal::RESULT_COUNT), response_code(-1) { 177 : result(captive_portal::RESULT_COUNT), response_code(-1) {
152 } 178 }
153 179
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 "CaptivePortal.Session.DetectionDuration"; 227 "CaptivePortal.Session.DetectionDuration";
202 const char NetworkPortalDetectorImpl::kSessionShillOnlineHistogram[] = 228 const char NetworkPortalDetectorImpl::kSessionShillOnlineHistogram[] =
203 "CaptivePortal.Session.DiscrepancyWithShill_Online"; 229 "CaptivePortal.Session.DiscrepancyWithShill_Online";
204 const char NetworkPortalDetectorImpl::kSessionShillPortalHistogram[] = 230 const char NetworkPortalDetectorImpl::kSessionShillPortalHistogram[] =
205 "CaptivePortal.Session.DiscrepancyWithShill_RestrictedPool"; 231 "CaptivePortal.Session.DiscrepancyWithShill_RestrictedPool";
206 const char NetworkPortalDetectorImpl::kSessionShillOfflineHistogram[] = 232 const char NetworkPortalDetectorImpl::kSessionShillOfflineHistogram[] =
207 "CaptivePortal.Session.DiscrepancyWithShill_Offline"; 233 "CaptivePortal.Session.DiscrepancyWithShill_Offline";
208 const char NetworkPortalDetectorImpl::kSessionPortalToOnlineHistogram[] = 234 const char NetworkPortalDetectorImpl::kSessionPortalToOnlineHistogram[] =
209 "CaptivePortal.Session.PortalToOnlineTransition"; 235 "CaptivePortal.Session.PortalToOnlineTransition";
210 236
211 // static 237 void InitializeNetworkPortalDetector(
212 void NetworkPortalDetectorImpl::Initialize(
213 net::URLRequestContextGetter* url_context) { 238 net::URLRequestContextGetter* url_context) {
214 if (set_for_testing()) 239 if (NetworkPortalDetector::set_for_testing())
215 return; 240 return;
216 CHECK(!network_portal_detector()) 241 CHECK(!NetworkPortalDetector::network_portal_detector())
217 << "NetworkPortalDetector was initialized twice."; 242 << "NetworkPortalDetector was initialized twice.";
218 NET_LOG(EVENT) << "NetworkPortalDetectorImpl::Initialize"; 243 NET_LOG(EVENT) << "NetworkPortalDetectorImpl::Initialize";
219 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 244 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
220 ::switches::kTestType)) { 245 ::switches::kTestType)) {
221 set_network_portal_detector(new NetworkPortalDetectorStub()); 246 NetworkPortalDetector::set_network_portal_detector(
247 new NetworkPortalDetectorStub());
222 } else { 248 } else {
223 set_network_portal_detector( 249 NetworkPortalDetector::set_network_portal_detector(
224 new NetworkPortalDetectorImpl(url_context, true)); 250 new NetworkPortalDetectorImpl(url_context, true));
225 } 251 }
226 } 252 }
227 253
228 NetworkPortalDetectorImpl::NetworkPortalDetectorImpl( 254 NetworkPortalDetectorImpl::NetworkPortalDetectorImpl(
229 const scoped_refptr<net::URLRequestContextGetter>& request_context, 255 const scoped_refptr<net::URLRequestContextGetter>& request_context,
230 bool create_notification_controller) 256 bool create_notification_controller)
231 : test_url_(CaptivePortalDetector::kDefaultURL), 257 : test_url_(CaptivePortalDetector::kDefaultURL),
232 strategy_(PortalDetectorStrategy::CreateById( 258 strategy_(PortalDetectorStrategy::CreateById(
233 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, 259 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN,
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 684 }
659 685
660 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() { 686 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() {
661 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; 687 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN;
662 same_detection_result_count_ = 0; 688 same_detection_result_count_ = 0;
663 no_response_result_count_ = 0; 689 no_response_result_count_ = 0;
664 strategy_->Reset(); 690 strategy_->Reset();
665 } 691 }
666 692
667 } // namespace chromeos 693 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698