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 "net/socket/socket_test_util.h" | 5 #include "net/socket/socket_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 MockSSLClientSocket::MockSSLClientSocket( | 1056 MockSSLClientSocket::MockSSLClientSocket( |
1057 ClientSocketHandle* transport_socket, | 1057 ClientSocketHandle* transport_socket, |
1058 const HostPortPair& host_port_pair, | 1058 const HostPortPair& host_port_pair, |
1059 const SSLConfig& ssl_config, | 1059 const SSLConfig& ssl_config, |
1060 SSLHostInfo* ssl_host_info, | 1060 SSLHostInfo* ssl_host_info, |
1061 SSLSocketDataProvider* data) | 1061 SSLSocketDataProvider* data) |
1062 : MockClientSocket(transport_socket->socket()->NetLog().net_log()), | 1062 : MockClientSocket(transport_socket->socket()->NetLog().net_log()), |
1063 transport_(transport_socket), | 1063 transport_(transport_socket), |
1064 data_(data), | 1064 data_(data), |
1065 is_npn_state_set_(false), | 1065 is_npn_state_set_(false), |
1066 new_npn_value_(false) { | 1066 new_npn_value_(false), |
| 1067 is_next_protocol_set_(false), |
| 1068 next_protocol_(kProtoHTTP11) { |
1067 DCHECK(data_); | 1069 DCHECK(data_); |
1068 delete ssl_host_info; // we take ownership but don't use it. | 1070 delete ssl_host_info; // we take ownership but don't use it. |
1069 } | 1071 } |
1070 | 1072 |
1071 MockSSLClientSocket::~MockSSLClientSocket() { | 1073 MockSSLClientSocket::~MockSSLClientSocket() { |
1072 Disconnect(); | 1074 Disconnect(); |
1073 } | 1075 } |
1074 | 1076 |
1075 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, | 1077 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, |
1076 const CompletionCallback& callback) { | 1078 const CompletionCallback& callback) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 if (is_npn_state_set_) | 1154 if (is_npn_state_set_) |
1153 return new_npn_value_; | 1155 return new_npn_value_; |
1154 return data_->was_npn_negotiated; | 1156 return data_->was_npn_negotiated; |
1155 } | 1157 } |
1156 | 1158 |
1157 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { | 1159 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { |
1158 is_npn_state_set_ = true; | 1160 is_npn_state_set_ = true; |
1159 return new_npn_value_ = negotiated; | 1161 return new_npn_value_ = negotiated; |
1160 } | 1162 } |
1161 | 1163 |
| 1164 SSLClientSocket::NextProto MockSSLClientSocket::next_protocol_negotiated() |
| 1165 const { |
| 1166 if (is_next_protocol_set_) |
| 1167 return next_protocol_; |
| 1168 return SSLClientSocket::NextProtoFromString(data_->next_proto); |
| 1169 } |
| 1170 |
| 1171 void MockSSLClientSocket::set_next_protocol_negotiated( |
| 1172 SSLClientSocket::NextProto next_protocol) { |
| 1173 is_next_protocol_set_ = true; |
| 1174 next_protocol_ = next_protocol; |
| 1175 } |
| 1176 |
1162 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { | 1177 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { |
1163 NOTIMPLEMENTED(); | 1178 NOTIMPLEMENTED(); |
1164 } | 1179 } |
1165 | 1180 |
1166 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, | 1181 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, |
1167 net::NetLog* net_log) | 1182 net::NetLog* net_log) |
1168 : connected_(false), | 1183 : connected_(false), |
1169 data_(data), | 1184 data_(data), |
1170 read_offset_(0), | 1185 read_offset_(0), |
1171 read_data_(false, ERR_UNEXPECTED), | 1186 read_data_(false, ERR_UNEXPECTED), |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 | 1616 |
1602 const char kSOCKS5OkRequest[] = | 1617 const char kSOCKS5OkRequest[] = |
1603 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1618 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1604 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1619 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1605 | 1620 |
1606 const char kSOCKS5OkResponse[] = | 1621 const char kSOCKS5OkResponse[] = |
1607 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1622 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1608 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1623 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1609 | 1624 |
1610 } // namespace net | 1625 } // namespace net |
OLD | NEW |