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.h" | 10 #include "base/message_loop.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // "failures", to trigger backoff. | 264 // "failures", to trigger backoff. |
265 backoff_entry_->SetCustomReleaseTime(now + retry_after_delta); | 265 backoff_entry_->SetCustomReleaseTime(now + retry_after_delta); |
266 backoff_entry_->InformOfRequest(false); | 266 backoff_entry_->InformOfRequest(false); |
267 } | 267 } |
268 | 268 |
269 last_check_time_ = now; | 269 last_check_time_ = now; |
270 | 270 |
271 OnResult(result); | 271 OnResult(result); |
272 } | 272 } |
273 | 273 |
274 void CaptivePortalService::Observe( | 274 void CaptivePortalService::OnPreferenceChanged(PrefServiceBase* service, |
275 int type, | 275 const std::string& pref_name) { |
276 const content::NotificationSource& source, | |
277 const content::NotificationDetails& details) { | |
278 DCHECK(CalledOnValidThread()); | 276 DCHECK(CalledOnValidThread()); |
279 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | 277 DCHECK_EQ(std::string(prefs::kAlternateErrorPagesEnabled), pref_name); |
280 DCHECK_EQ(std::string(prefs::kAlternateErrorPagesEnabled), | |
281 *content::Details<std::string>(details).ptr()); | |
282 UpdateEnabledState(); | 278 UpdateEnabledState(); |
283 } | 279 } |
284 | 280 |
285 void CaptivePortalService::Shutdown() { | 281 void CaptivePortalService::Shutdown() { |
286 DCHECK(CalledOnValidThread()); | 282 DCHECK(CalledOnValidThread()); |
287 if (enabled_) { | 283 if (enabled_) { |
288 RecordRepeatHistograms( | 284 RecordRepeatHistograms( |
289 last_detection_result_, | 285 last_detection_result_, |
290 num_checks_with_same_result_, | 286 num_checks_with_same_result_, |
291 GetCurrentTimeTicks() - first_check_time_with_same_result_); | 287 GetCurrentTimeTicks() - first_check_time_with_same_result_); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 359 |
364 bool CaptivePortalService::DetectionInProgress() const { | 360 bool CaptivePortalService::DetectionInProgress() const { |
365 return state_ == STATE_CHECKING_FOR_PORTAL; | 361 return state_ == STATE_CHECKING_FOR_PORTAL; |
366 } | 362 } |
367 | 363 |
368 bool CaptivePortalService::TimerRunning() const { | 364 bool CaptivePortalService::TimerRunning() const { |
369 return check_captive_portal_timer_.IsRunning(); | 365 return check_captive_portal_timer_.IsRunning(); |
370 } | 366 } |
371 | 367 |
372 } // namespace captive_portal | 368 } // namespace captive_portal |
OLD | NEW |