| 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 "components/captive_portal/captive_portal_detector.h" | 5 #include "components/captive_portal/captive_portal_detector.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 9 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
| 10 #include "net/http/http_response_headers.h" | 11 #include "net/http/http_response_headers.h" |
| 11 #include "net/http/http_util.h" | 12 #include "net/http/http_util.h" |
| 12 #include "net/url_request/url_request_status.h" | 13 #include "net/url_request/url_request_status.h" |
| 13 | 14 |
| 14 namespace captive_portal { | 15 namespace captive_portal { |
| 15 | 16 |
| 16 const char CaptivePortalDetector::kDefaultURL[] = | 17 const char CaptivePortalDetector::kDefaultURL[] = |
| 17 "http://www.gstatic.com/generate_204"; | 18 "http://www.gstatic.com/generate_204"; |
| 18 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 DCHECK(CalledOnValidThread()); | 31 DCHECK(CalledOnValidThread()); |
| 31 DCHECK(!FetchingURL()); | 32 DCHECK(!FetchingURL()); |
| 32 DCHECK(detection_callback_.is_null()); | 33 DCHECK(detection_callback_.is_null()); |
| 33 | 34 |
| 34 detection_callback_ = detection_callback; | 35 detection_callback_ = detection_callback; |
| 35 | 36 |
| 36 // The first 0 means this can use a TestURLFetcherFactory in unit tests. | 37 // The first 0 means this can use a TestURLFetcherFactory in unit tests. |
| 37 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); | 38 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); |
| 38 url_fetcher_->SetAutomaticallyRetryOn5xx(false); | 39 url_fetcher_->SetAutomaticallyRetryOn5xx(false); |
| 39 url_fetcher_->SetRequestContext(request_context_.get()); | 40 url_fetcher_->SetRequestContext(request_context_.get()); |
| 41 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 42 url_fetcher_.get(), |
| 43 data_use_measurement::DataUseUserData::CAPTIVE_PORTAL); |
| 40 | 44 |
| 41 // Can't safely use net::LOAD_DISABLE_CERT_REVOCATION_CHECKING here, | 45 // Can't safely use net::LOAD_DISABLE_CERT_REVOCATION_CHECKING here, |
| 42 // since then the connection may be reused without checking the cert. | 46 // since then the connection may be reused without checking the cert. |
| 43 url_fetcher_->SetLoadFlags( | 47 url_fetcher_->SetLoadFlags( |
| 44 net::LOAD_BYPASS_CACHE | | 48 net::LOAD_BYPASS_CACHE | |
| 45 net::LOAD_DO_NOT_SAVE_COOKIES | | 49 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 46 net::LOAD_DO_NOT_SEND_COOKIES | | 50 net::LOAD_DO_NOT_SEND_COOKIES | |
| 47 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 51 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| 48 url_fetcher_->Start(); | 52 url_fetcher_->Start(); |
| 49 } | 53 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return base::Time::Now(); | 141 return base::Time::Now(); |
| 138 else | 142 else |
| 139 return time_for_testing_; | 143 return time_for_testing_; |
| 140 } | 144 } |
| 141 | 145 |
| 142 bool CaptivePortalDetector::FetchingURL() const { | 146 bool CaptivePortalDetector::FetchingURL() const { |
| 143 return url_fetcher_.get() != NULL; | 147 return url_fetcher_.get() != NULL; |
| 144 } | 148 } |
| 145 | 149 |
| 146 } // namespace captive_portal | 150 } // namespace captive_portal |
| OLD | NEW |