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/profiler/scoped_profile.h" | 8 #include "base/profiler/scoped_tracker.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
11 #include "net/http/http_response_headers.h" | 11 #include "net/http/http_response_headers.h" |
12 #include "net/url_request/url_request_status.h" | 12 #include "net/url_request/url_request_status.h" |
13 | 13 |
14 namespace captive_portal { | 14 namespace captive_portal { |
15 | 15 |
16 const char CaptivePortalDetector::kDefaultURL[] = | 16 const char CaptivePortalDetector::kDefaultURL[] = |
17 "http://www.gstatic.com/generate_204"; | 17 "http://www.gstatic.com/generate_204"; |
18 | 18 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 51 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
52 url_fetcher_->Start(); | 52 url_fetcher_->Start(); |
53 } | 53 } |
54 | 54 |
55 void CaptivePortalDetector::Cancel() { | 55 void CaptivePortalDetector::Cancel() { |
56 url_fetcher_.reset(); | 56 url_fetcher_.reset(); |
57 detection_callback_.Reset(); | 57 detection_callback_.Reset(); |
58 } | 58 } |
59 | 59 |
60 void CaptivePortalDetector::OnURLFetchComplete(const net::URLFetcher* source) { | 60 void CaptivePortalDetector::OnURLFetchComplete(const net::URLFetcher* source) { |
61 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. | 61 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422577 is fixed. |
62 tracked_objects::ScopedProfile tracking_profile( | 62 tracked_objects::ScopedTracker tracking_profile( |
63 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 63 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
64 "422577 CaptivePortalDetector::OnURLFetchComplete")); | 64 "422577 CaptivePortalDetector::OnURLFetchComplete")); |
65 | 65 |
66 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
67 DCHECK(FetchingURL()); | 67 DCHECK(FetchingURL()); |
68 DCHECK_EQ(url_fetcher_.get(), source); | 68 DCHECK_EQ(url_fetcher_.get(), source); |
69 DCHECK(!detection_callback_.is_null()); | 69 DCHECK(!detection_callback_.is_null()); |
70 | 70 |
71 Results results; | 71 Results results; |
72 GetCaptivePortalResultFromResponse(url_fetcher_.get(), &results); | 72 GetCaptivePortalResultFromResponse(url_fetcher_.get(), &results); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return base::Time::Now(); | 145 return base::Time::Now(); |
146 else | 146 else |
147 return time_for_testing_; | 147 return time_for_testing_; |
148 } | 148 } |
149 | 149 |
150 bool CaptivePortalDetector::FetchingURL() const { | 150 bool CaptivePortalDetector::FetchingURL() const { |
151 return url_fetcher_.get() != NULL; | 151 return url_fetcher_.get() != NULL; |
152 } | 152 } |
153 | 153 |
154 } // namespace captive_portal | 154 } // namespace captive_portal |
OLD | NEW |