| 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 "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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip); | 999 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip); |
| 1000 CHECK(rv); | 1000 CHECK(rv); |
| 1001 *address = IPEndPoint(ip, 123); | 1001 *address = IPEndPoint(ip, 123); |
| 1002 return OK; | 1002 return OK; |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 const BoundNetLog& MockClientSocket::NetLog() const { | 1005 const BoundNetLog& MockClientSocket::NetLog() const { |
| 1006 return net_log_; | 1006 return net_log_; |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 void MockClientSocket::GetConnectionAttempts(ConnectionAttempts* out) const { |
| 1010 out->clear(); |
| 1011 } |
| 1012 |
| 1009 void MockClientSocket::GetSSLCertRequestInfo( | 1013 void MockClientSocket::GetSSLCertRequestInfo( |
| 1010 SSLCertRequestInfo* cert_request_info) { | 1014 SSLCertRequestInfo* cert_request_info) { |
| 1011 } | 1015 } |
| 1012 | 1016 |
| 1013 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, | 1017 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, |
| 1014 bool has_context, | 1018 bool has_context, |
| 1015 const base::StringPiece& context, | 1019 const base::StringPiece& context, |
| 1016 unsigned char* out, | 1020 unsigned char* out, |
| 1017 unsigned int outlen) { | 1021 unsigned int outlen) { |
| 1018 memset(out, 'A', outlen); | 1022 memset(out, 'A', outlen); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 // TODO(rch): remove this once OrderedSocketData and DelayedSocketData | 1145 // TODO(rch): remove this once OrderedSocketData and DelayedSocketData |
| 1142 // have been removed. | 1146 // have been removed. |
| 1143 if (write_result.mode == ASYNC) { | 1147 if (write_result.mode == ASYNC) { |
| 1144 RunCallbackAsync(callback, write_result.result); | 1148 RunCallbackAsync(callback, write_result.result); |
| 1145 return ERR_IO_PENDING; | 1149 return ERR_IO_PENDING; |
| 1146 } | 1150 } |
| 1147 | 1151 |
| 1148 return write_result.result; | 1152 return write_result.result; |
| 1149 } | 1153 } |
| 1150 | 1154 |
| 1155 void MockTCPClientSocket::GetConnectionAttempts(ConnectionAttempts* out) const { |
| 1156 int connect_result = data_->connect_data().result; |
| 1157 |
| 1158 out->clear(); |
| 1159 if (connected_ && connect_result != OK) |
| 1160 out->push_back(ConnectionAttempt(addresses_[0], connect_result)); |
| 1161 } |
| 1162 |
| 1163 void MockTCPClientSocket::ClearConnectionAttempts() { |
| 1164 NOTIMPLEMENTED(); |
| 1165 } |
| 1166 |
| 1167 void MockTCPClientSocket::AddConnectionAttempts(const ConnectionAttempts& in) { |
| 1168 NOTIMPLEMENTED(); |
| 1169 } |
| 1170 |
| 1151 int MockTCPClientSocket::Connect(const CompletionCallback& callback) { | 1171 int MockTCPClientSocket::Connect(const CompletionCallback& callback) { |
| 1152 if (connected_) | 1172 if (connected_) |
| 1153 return OK; | 1173 return OK; |
| 1154 connected_ = true; | 1174 connected_ = true; |
| 1155 peer_closed_connection_ = false; | 1175 peer_closed_connection_ = false; |
| 1156 if (data_->connect_data().mode == ASYNC) { | 1176 if (data_->connect_data().mode == ASYNC) { |
| 1157 if (data_->connect_data().result == ERR_IO_PENDING) | 1177 if (data_->connect_data().result == ERR_IO_PENDING) |
| 1158 pending_read_callback_ = callback; | 1178 pending_read_callback_ = callback; |
| 1159 else | 1179 else |
| 1160 RunCallbackAsync(callback, data_->connect_data().result); | 1180 RunCallbackAsync(callback, data_->connect_data().result); |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 | 2199 |
| 2180 const char kSOCKS5OkRequest[] = | 2200 const char kSOCKS5OkRequest[] = |
| 2181 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2201 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 2182 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2202 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 2183 | 2203 |
| 2184 const char kSOCKS5OkResponse[] = | 2204 const char kSOCKS5OkResponse[] = |
| 2185 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2205 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 2186 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2206 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 2187 | 2207 |
| 2188 } // namespace net | 2208 } // namespace net |
| OLD | NEW |