OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/captive_portal/captive_portal_service.h" | 5 #include "chrome/browser/captive_portal/captive_portal_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 207 |
208 UpdateEnabledState(); | 208 UpdateEnabledState(); |
209 } | 209 } |
210 | 210 |
211 CaptivePortalService::~CaptivePortalService() { | 211 CaptivePortalService::~CaptivePortalService() { |
212 } | 212 } |
213 | 213 |
214 void CaptivePortalService::DetectCaptivePortal() { | 214 void CaptivePortalService::DetectCaptivePortal() { |
215 DCHECK(CalledOnValidThread()); | 215 DCHECK(CalledOnValidThread()); |
216 | 216 |
217 // Detection should be disabled only in tests. | |
218 if (testing_state_ == IGNORE_REQUESTS_FOR_TESTING) | |
219 return; | |
220 | |
217 // If a request is pending or running, do nothing. | 221 // If a request is pending or running, do nothing. |
218 if (state_ == STATE_CHECKING_FOR_PORTAL || state_ == STATE_TIMER_RUNNING) | 222 if (state_ == STATE_CHECKING_FOR_PORTAL || state_ == STATE_TIMER_RUNNING) |
219 return; | 223 return; |
220 | 224 |
221 base::TimeDelta time_until_next_check = backoff_entry_->GetTimeUntilRelease(); | 225 base::TimeDelta time_until_next_check = backoff_entry_->GetTimeUntilRelease(); |
222 | 226 |
223 // Start asynchronously. | 227 // Start asynchronously. |
224 state_ = STATE_TIMER_RUNNING; | 228 state_ = STATE_TIMER_RUNNING; |
225 check_captive_portal_timer_.Start( | 229 check_captive_portal_timer_.Start( |
226 FROM_HERE, | 230 FROM_HERE, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 | 352 |
349 backoff_entry_.reset(new RecheckBackoffEntry(this)); | 353 backoff_entry_.reset(new RecheckBackoffEntry(this)); |
350 } | 354 } |
351 | 355 |
352 void CaptivePortalService::UpdateEnabledState() { | 356 void CaptivePortalService::UpdateEnabledState() { |
353 DCHECK(CalledOnValidThread()); | 357 DCHECK(CalledOnValidThread()); |
354 bool enabled_before = enabled_; | 358 bool enabled_before = enabled_; |
355 enabled_ = testing_state_ != DISABLED_FOR_TESTING && | 359 enabled_ = testing_state_ != DISABLED_FOR_TESTING && |
356 resolve_errors_with_web_service_.GetValue(); | 360 resolve_errors_with_web_service_.GetValue(); |
357 | 361 |
358 if (testing_state_ != SKIP_OS_CHECK_FOR_TESTING && | 362 if (testing_state_ != SKIP_OS_CHECK_FOR_TESTING && |
mmenke
2014/12/15 20:46:08
testing_state_ != SKIP_OS_CHECK_FOR_TESTING &&
tes
meacer
2014/12/16 01:23:19
Done.
| |
359 ShouldDeferToNativeCaptivePortalDetection()) { | 363 ShouldDeferToNativeCaptivePortalDetection()) { |
360 enabled_ = false; | 364 enabled_ = false; |
361 } | 365 } |
362 | 366 |
363 if (enabled_before == enabled_) | 367 if (enabled_before == enabled_) |
364 return; | 368 return; |
365 | 369 |
366 // Clear data used for histograms. | 370 // Clear data used for histograms. |
367 num_checks_with_same_result_ = 0; | 371 num_checks_with_same_result_ = 0; |
368 first_check_time_with_same_result_ = base::TimeTicks(); | 372 first_check_time_with_same_result_ = base::TimeTicks(); |
(...skipping 21 matching lines...) Expand all Loading... | |
390 return time_ticks_for_testing_; | 394 return time_ticks_for_testing_; |
391 } | 395 } |
392 | 396 |
393 bool CaptivePortalService::DetectionInProgress() const { | 397 bool CaptivePortalService::DetectionInProgress() const { |
394 return state_ == STATE_CHECKING_FOR_PORTAL; | 398 return state_ == STATE_CHECKING_FOR_PORTAL; |
395 } | 399 } |
396 | 400 |
397 bool CaptivePortalService::TimerRunning() const { | 401 bool CaptivePortalService::TimerRunning() const { |
398 return check_captive_portal_timer_.IsRunning(); | 402 return check_captive_portal_timer_.IsRunning(); |
399 } | 403 } |
OLD | NEW |