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