| 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/chrome_async_socket.h" | 5 #include "jingle/glue/chrome_async_socket.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "jingle/glue/resolving_client_socket_factory.h" | 16 #include "jingle/glue/resolving_client_socket_factory.h" |
| 17 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
| 18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 #include "net/socket/client_socket_handle.h" | 21 #include "net/socket/client_socket_handle.h" |
| 22 #include "net/socket/ssl_client_socket.h" | 22 #include "net/socket/ssl_client_socket.h" |
| 23 #include "net/socket/tcp_client_socket.h" | 23 #include "net/socket/tcp_client_socket.h" |
| 24 #include "net/ssl/ssl_config_service.h" | 24 #include "net/ssl/ssl_config_service.h" |
| 25 #include "third_party/libjingle/source/talk/base/socketaddress.h" | 25 #include "third_party/webrtc/base/socketaddress.h" |
| 26 | 26 |
| 27 namespace jingle_glue { | 27 namespace jingle_glue { |
| 28 | 28 |
| 29 ChromeAsyncSocket::ChromeAsyncSocket( | 29 ChromeAsyncSocket::ChromeAsyncSocket( |
| 30 ResolvingClientSocketFactory* resolving_client_socket_factory, | 30 ResolvingClientSocketFactory* resolving_client_socket_factory, |
| 31 size_t read_buf_size, | 31 size_t read_buf_size, |
| 32 size_t write_buf_size) | 32 size_t write_buf_size) |
| 33 : resolving_client_socket_factory_(resolving_client_socket_factory), | 33 : resolving_client_socket_factory_(resolving_client_socket_factory), |
| 34 state_(STATE_CLOSED), | 34 state_(STATE_CLOSED), |
| 35 error_(ERROR_NONE), | 35 error_(ERROR_NONE), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 net_error_ = net_error; | 77 net_error_ = net_error; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ChromeAsyncSocket::DoNetErrorFromStatus(int status) { | 80 void ChromeAsyncSocket::DoNetErrorFromStatus(int status) { |
| 81 DCHECK_LT(status, net::OK); | 81 DCHECK_LT(status, net::OK); |
| 82 DoNetError(static_cast<net::Error>(status)); | 82 DoNetError(static_cast<net::Error>(status)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // STATE_CLOSED -> STATE_CONNECTING | 85 // STATE_CLOSED -> STATE_CONNECTING |
| 86 | 86 |
| 87 bool ChromeAsyncSocket::Connect(const talk_base::SocketAddress& address) { | 87 bool ChromeAsyncSocket::Connect(const rtc::SocketAddress& address) { |
| 88 if (state_ != STATE_CLOSED) { | 88 if (state_ != STATE_CLOSED) { |
| 89 LOG(DFATAL) << "Connect() called on non-closed socket"; | 89 LOG(DFATAL) << "Connect() called on non-closed socket"; |
| 90 DoNonNetError(ERROR_WRONGSTATE); | 90 DoNonNetError(ERROR_WRONGSTATE); |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 if (address.hostname().empty() || address.port() == 0) { | 93 if (address.hostname().empty() || address.port() == 0) { |
| 94 DoNonNetError(ERROR_DNS); | 94 DoNonNetError(ERROR_DNS); |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 | 97 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 } | 441 } |
| 442 state_ = STATE_TLS_OPEN; | 442 state_ = STATE_TLS_OPEN; |
| 443 PostDoRead(); | 443 PostDoRead(); |
| 444 if (write_end_ > 0U) { | 444 if (write_end_ > 0U) { |
| 445 PostDoWrite(); | 445 PostDoWrite(); |
| 446 } | 446 } |
| 447 SignalSSLConnected(); | 447 SignalSSLConnected(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 } // namespace jingle_glue | 450 } // namespace jingle_glue |
| OLD | NEW |