| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/net/connectivity_checker.h" | 5 #include "chromecast/net/connectivity_checker.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chromecast/net/net_switches.h" | 10 #include "chromecast/net/net_switches.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 DCHECK(url_request_context_.get()); | 106 DCHECK(url_request_context_.get()); |
| 107 | 107 |
| 108 // If url_request_ is non-null, there is already a check going on. Don't | 108 // If url_request_ is non-null, there is already a check going on. Don't |
| 109 // start another. | 109 // start another. |
| 110 if (url_request_.get()) | 110 if (url_request_.get()) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 VLOG(1) << "Connectivity check: url=" << *connectivity_check_url_; | 113 VLOG(1) << "Connectivity check: url=" << *connectivity_check_url_; |
| 114 url_request_ = url_request_context_->CreateRequest( | 114 url_request_ = url_request_context_->CreateRequest( |
| 115 *connectivity_check_url_, net::MAXIMUM_PRIORITY, this, NULL); | 115 *connectivity_check_url_, net::MAXIMUM_PRIORITY, this); |
| 116 url_request_->set_method("HEAD"); | 116 url_request_->set_method("HEAD"); |
| 117 url_request_->Start(); | 117 url_request_->Start(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ConnectivityChecker::OnConnectionTypeChanged( | 120 void ConnectivityChecker::OnConnectionTypeChanged( |
| 121 net::NetworkChangeNotifier::ConnectionType type) { | 121 net::NetworkChangeNotifier::ConnectionType type) { |
| 122 VLOG(2) << "OnConnectionTypeChanged " << type; | 122 VLOG(2) << "OnConnectionTypeChanged " << type; |
| 123 if (type == net::NetworkChangeNotifier::CONNECTION_NONE) | 123 if (type == net::NetworkChangeNotifier::CONNECTION_NONE) |
| 124 SetConnectivity(false); | 124 SetConnectivity(false); |
| 125 | 125 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 void ConnectivityChecker::Cancel() { | 172 void ConnectivityChecker::Cancel() { |
| 173 if (url_request_.get()) { | 173 if (url_request_.get()) { |
| 174 VLOG(2) << "Cancel connectivity check in progress"; | 174 VLOG(2) << "Cancel connectivity check in progress"; |
| 175 url_request_.reset(NULL); // URLRequest::Cancel() is called in destructor. | 175 url_request_.reset(NULL); // URLRequest::Cancel() is called in destructor. |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace chromecast | 179 } // namespace chromecast |
| OLD | NEW |