Chromium Code Reviews| 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 "jingle/glue/proxy_resolving_client_socket.h" | 5 #include "jingle/glue/proxy_resolving_client_socket.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | |
| 14 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 15 #include "net/base/ip_address.h" | 16 #include "net/base/ip_address.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/http/http_auth_controller.h" | 19 #include "net/http/http_auth_controller.h" |
| 19 #include "net/http/http_network_session.h" | 20 #include "net/http/http_network_session.h" |
| 20 #include "net/http/proxy_client_socket.h" | 21 #include "net/http/proxy_client_socket.h" |
| 21 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
| 22 #include "net/socket/client_socket_pool_manager.h" | 23 #include "net/socket/client_socket_pool_manager.h" |
| 23 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 net::LOAD_NORMAL, | 143 net::LOAD_NORMAL, |
| 143 &proxy_info_, | 144 &proxy_info_, |
| 144 proxy_resolve_callback_, | 145 proxy_resolve_callback_, |
| 145 &pac_request_, | 146 &pac_request_, |
| 146 NULL, | 147 NULL, |
| 147 bound_net_log_); | 148 bound_net_log_); |
| 148 if (status != net::ERR_IO_PENDING) { | 149 if (status != net::ERR_IO_PENDING) { |
| 149 // We defer execution of ProcessProxyResolveDone instead of calling it | 150 // We defer execution of ProcessProxyResolveDone instead of calling it |
| 150 // directly here for simplicity. From the caller's point of view, | 151 // directly here for simplicity. From the caller's point of view, |
| 151 // the connect always happens asynchronously. | 152 // the connect always happens asynchronously. |
| 152 base::MessageLoop* message_loop = base::MessageLoop::current(); | 153 CHECK(base::ThreadTaskRunnerHandle::IsSet()); |
|
Sergey Ulanov
2016/06/20 22:53:25
I don't think you need this CHECK(). There is DCHE
fdoray
2016/06/21 13:01:51
Done. I didn't want to replace a CHECK with a DCHE
| |
| 153 CHECK(message_loop); | 154 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 154 message_loop->PostTask( | |
| 155 FROM_HERE, | 155 FROM_HERE, |
| 156 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, | 156 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, |
| 157 weak_factory_.GetWeakPtr(), status)); | 157 weak_factory_.GetWeakPtr(), status)); |
| 158 } | 158 } |
| 159 user_connect_callback_ = callback; | 159 user_connect_callback_ = callback; |
| 160 return net::ERR_IO_PENDING; | 160 return net::ERR_IO_PENDING; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ProxyResolvingClientSocket::RunUserConnectCallback(int status) { | 163 void ProxyResolvingClientSocket::RunUserConnectCallback(int status) { |
| 164 DCHECK_LE(status, net::OK); | 164 DCHECK_LE(status, net::OK); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 // If ReconsiderProxyAfterError() failed synchronously, it means | 298 // If ReconsiderProxyAfterError() failed synchronously, it means |
| 299 // there was nothing left to fall-back to, so fail the transaction | 299 // there was nothing left to fall-back to, so fail the transaction |
| 300 // with the last connection error we got. | 300 // with the last connection error we got. |
| 301 rv = error; | 301 rv = error; |
| 302 } | 302 } |
| 303 | 303 |
| 304 // We either have new proxy info or there was an error in falling back. | 304 // We either have new proxy info or there was an error in falling back. |
| 305 // In both cases we want to post ProcessProxyResolveDone (in the error case | 305 // In both cases we want to post ProcessProxyResolveDone (in the error case |
| 306 // we might still want to fall back a direct connection). | 306 // we might still want to fall back a direct connection). |
| 307 if (rv != net::ERR_IO_PENDING) { | 307 if (rv != net::ERR_IO_PENDING) { |
| 308 base::MessageLoop* message_loop = base::MessageLoop::current(); | 308 CHECK(base::ThreadTaskRunnerHandle::IsSet()); |
| 309 CHECK(message_loop); | 309 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 310 message_loop->PostTask( | |
| 311 FROM_HERE, | 310 FROM_HERE, |
| 312 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, | 311 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, |
| 313 weak_factory_.GetWeakPtr(), rv)); | 312 weak_factory_.GetWeakPtr(), rv)); |
| 314 // Since we potentially have another try to go (trying the direct connect) | 313 // Since we potentially have another try to go (trying the direct connect) |
| 315 // set the return code code to ERR_IO_PENDING. | 314 // set the return code code to ERR_IO_PENDING. |
| 316 rv = net::ERR_IO_PENDING; | 315 rv = net::ERR_IO_PENDING; |
| 317 } | 316 } |
| 318 return rv; | 317 return rv; |
| 319 } | 318 } |
| 320 | 319 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 return 0; | 423 return 0; |
| 425 } | 424 } |
| 426 | 425 |
| 427 void ProxyResolvingClientSocket::CloseTransportSocket() { | 426 void ProxyResolvingClientSocket::CloseTransportSocket() { |
| 428 if (transport_.get() && transport_->socket()) | 427 if (transport_.get() && transport_->socket()) |
| 429 transport_->socket()->Disconnect(); | 428 transport_->socket()->Disconnect(); |
| 430 transport_.reset(); | 429 transport_.reset(); |
| 431 } | 430 } |
| 432 | 431 |
| 433 } // namespace jingle_glue | 432 } // namespace jingle_glue |
| OLD | NEW |