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 "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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 SSLSocketDataProvider* data) | 1278 SSLSocketDataProvider* data) |
| 1279 : MockClientSocket( | 1279 : MockClientSocket( |
| 1280 // Have to use the right BoundNetLog for LoadTimingInfo regression | 1280 // Have to use the right BoundNetLog for LoadTimingInfo regression |
| 1281 // tests. | 1281 // tests. |
| 1282 transport_socket->socket()->NetLog()), | 1282 transport_socket->socket()->NetLog()), |
| 1283 transport_(transport_socket), | 1283 transport_(transport_socket), |
| 1284 data_(data), | 1284 data_(data), |
| 1285 is_npn_state_set_(false), | 1285 is_npn_state_set_(false), |
| 1286 new_npn_value_(false), | 1286 new_npn_value_(false), |
| 1287 is_protocol_negotiated_set_(false), | 1287 is_protocol_negotiated_set_(false), |
| 1288 was_spdy_negotiated_(false), | |
| 1289 was_spdy_negotiated_set_(false), | |
| 1288 protocol_negotiated_(kProtoUnknown) { | 1290 protocol_negotiated_(kProtoUnknown) { |
| 1289 DCHECK(data_); | 1291 DCHECK(data_); |
| 1290 peer_addr_ = data->connect.peer_addr; | 1292 peer_addr_ = data->connect.peer_addr; |
| 1291 } | 1293 } |
| 1292 | 1294 |
| 1293 MockSSLClientSocket::~MockSSLClientSocket() { | 1295 MockSSLClientSocket::~MockSSLClientSocket() { |
| 1294 Disconnect(); | 1296 Disconnect(); |
| 1295 } | 1297 } |
| 1296 | 1298 |
| 1297 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, | 1299 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1342 } | 1344 } |
| 1343 | 1345 |
| 1344 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1346 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
| 1345 ssl_info->Reset(); | 1347 ssl_info->Reset(); |
| 1346 ssl_info->cert = data_->cert; | 1348 ssl_info->cert = data_->cert; |
| 1347 ssl_info->client_cert_sent = data_->client_cert_sent; | 1349 ssl_info->client_cert_sent = data_->client_cert_sent; |
| 1348 ssl_info->channel_id_sent = data_->channel_id_sent; | 1350 ssl_info->channel_id_sent = data_->channel_id_sent; |
| 1349 return true; | 1351 return true; |
| 1350 } | 1352 } |
| 1351 | 1353 |
| 1354 bool MockSSLClientSocket::was_spdy_negotiated() const { | |
| 1355 // If the value is set explicitly, use the value. | |
| 1356 if (was_spdy_negotiated_set_) | |
| 1357 return was_spdy_negotiated_; | |
| 1358 // Otherwise derive the value from other information. | |
|
mmenke
2013/06/05 00:01:20
Still not following why this is needed - all tests
yhirano
2013/06/06 14:06:43
You are right. Done.
| |
| 1359 return WasNpnNegotiated() && | |
| 1360 kProtoSPDYMinimumVersion <= GetNegotiatedProtocol() && | |
| 1361 GetNegotiatedProtocol() <= kProtoSPDYMaximumVersion; | |
| 1362 } | |
| 1363 | |
| 1364 bool MockSSLClientSocket::set_was_spdy_negotiated(bool negotiated) { | |
| 1365 was_spdy_negotiated_set_ = true; | |
| 1366 was_spdy_negotiated_ = negotiated; | |
| 1367 return was_spdy_negotiated_; | |
| 1368 } | |
| 1369 | |
| 1352 void MockSSLClientSocket::GetSSLCertRequestInfo( | 1370 void MockSSLClientSocket::GetSSLCertRequestInfo( |
| 1353 SSLCertRequestInfo* cert_request_info) { | 1371 SSLCertRequestInfo* cert_request_info) { |
| 1354 DCHECK(cert_request_info); | 1372 DCHECK(cert_request_info); |
| 1355 if (data_->cert_request_info) { | 1373 if (data_->cert_request_info) { |
| 1356 cert_request_info->host_and_port = | 1374 cert_request_info->host_and_port = |
| 1357 data_->cert_request_info->host_and_port; | 1375 data_->cert_request_info->host_and_port; |
| 1358 cert_request_info->client_certs = data_->cert_request_info->client_certs; | 1376 cert_request_info->client_certs = data_->cert_request_info->client_certs; |
| 1359 } else { | 1377 } else { |
| 1360 cert_request_info->Reset(); | 1378 cert_request_info->Reset(); |
| 1361 } | 1379 } |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1848 | 1866 |
| 1849 const char kSOCKS5OkRequest[] = | 1867 const char kSOCKS5OkRequest[] = |
| 1850 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1868 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 1851 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1869 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 1852 | 1870 |
| 1853 const char kSOCKS5OkResponse[] = | 1871 const char kSOCKS5OkResponse[] = |
| 1854 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1872 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 1855 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1873 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 1856 | 1874 |
| 1857 } // namespace net | 1875 } // namespace net |
| OLD | NEW |