Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "jingle/notifier/base/proxy_resolving_client_socket.h" | 5 #include "jingle/notifier/base/proxy_resolving_client_socket.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 CloseTransportSocket(); | 165 CloseTransportSocket(); |
| 166 RunUserConnectCallback(status); | 166 RunUserConnectCallback(status); |
| 167 return; | 167 return; |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 transport_.reset(new net::ClientSocketHandle); | 171 transport_.reset(new net::ClientSocketHandle); |
| 172 // Now that we have resolved the proxy, we need to connect. | 172 // Now that we have resolved the proxy, we need to connect. |
| 173 status = net::InitSocketHandleForRawConnect( | 173 status = net::InitSocketHandleForRawConnect( |
| 174 dest_host_port_pair_, network_session_.get(), proxy_info_, ssl_config_, | 174 dest_host_port_pair_, network_session_.get(), proxy_info_, ssl_config_, |
| 175 ssl_config_, bound_net_log_, transport_.get(), connect_callback_); | 175 ssl_config_, bound_net_log_, transport_.get(), connect_callback_, |
| 176 base::Bind(&ProxyResolvingClientSocket::OnNeedsProxyTunnelAuthCallback, | |
| 177 weak_factory_.GetWeakPtr())); | |
| 178 | |
| 176 if (status != net::ERR_IO_PENDING) { | 179 if (status != net::ERR_IO_PENDING) { |
| 177 // Since this method is always called asynchronously. it is OK to call | 180 // Since this method is always called asynchronously. it is OK to call |
| 178 // ProcessConnectDone synchronously. | 181 // ProcessConnectDone synchronously. |
| 179 ProcessConnectDone(status); | 182 ProcessConnectDone(status); |
| 180 } | 183 } |
| 181 } | 184 } |
| 182 | 185 |
| 186 void ProxyResolvingClientSocket::OnNeedsProxyTunnelAuthCallback( | |
|
akalin
2012/01/19 22:12:48
actually, since this function doesn't do much, it
Ryan Hamilton
2012/01/19 23:11:19
Done. (Love it!)
| |
| 187 const net::HttpResponseInfo& response_info, | |
| 188 net::HttpAuthController* auth_controller, | |
| 189 net::CompletionCallback callback) { | |
| 190 // Since have not way to respond, simply invoke the callback and the | |
| 191 // request will fail. | |
| 192 callback.Run(net::OK); | |
| 193 } | |
| 194 | |
| 183 void ProxyResolvingClientSocket::ProcessConnectDone(int status) { | 195 void ProxyResolvingClientSocket::ProcessConnectDone(int status) { |
| 184 if (status != net::OK) { | 196 if (status != net::OK) { |
| 185 // If the connection fails, try another proxy. | 197 // If the connection fails, try another proxy. |
| 186 status = ReconsiderProxyAfterError(status); | 198 status = ReconsiderProxyAfterError(status); |
| 187 // ReconsiderProxyAfterError either returns an error (in which case it is | 199 // ReconsiderProxyAfterError either returns an error (in which case it is |
| 188 // not reconsidering a proxy) or returns ERR_IO_PENDING if it is considering | 200 // not reconsidering a proxy) or returns ERR_IO_PENDING if it is considering |
| 189 // another proxy. | 201 // another proxy. |
| 190 DCHECK_NE(status, net::OK); | 202 DCHECK_NE(status, net::OK); |
| 191 if (status == net::ERR_IO_PENDING) | 203 if (status == net::ERR_IO_PENDING) |
| 192 // Proxy reconsideration pending. Return. | 204 // Proxy reconsideration pending. Return. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 return base::TimeDelta::FromMicroseconds(-1); | 378 return base::TimeDelta::FromMicroseconds(-1); |
| 367 } | 379 } |
| 368 | 380 |
| 369 void ProxyResolvingClientSocket::CloseTransportSocket() { | 381 void ProxyResolvingClientSocket::CloseTransportSocket() { |
| 370 if (transport_.get() && transport_->socket()) | 382 if (transport_.get() && transport_->socket()) |
| 371 transport_->socket()->Disconnect(); | 383 transport_->socket()->Disconnect(); |
| 372 transport_.reset(); | 384 transport_.reset(); |
| 373 } | 385 } |
| 374 | 386 |
| 375 } // namespace notifier | 387 } // namespace notifier |
| OLD | NEW |