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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback_helpers.h" | |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "net/base/address_family.h" | 18 #include "net/base/address_family.h" |
| 18 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
| 19 #include "net/base/auth.h" | 20 #include "net/base/auth.h" |
| 20 #include "net/base/load_timing_info.h" | 21 #include "net/base/load_timing_info.h" |
| 21 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 } | 271 } |
| 271 | 272 |
| 272 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) | 273 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) |
| 273 : connect(mode, result), | 274 : connect(mode, result), |
| 274 next_proto_status(SSLClientSocket::kNextProtoUnsupported), | 275 next_proto_status(SSLClientSocket::kNextProtoUnsupported), |
| 275 was_npn_negotiated(false), | 276 was_npn_negotiated(false), |
| 276 protocol_negotiated(kProtoUnknown), | 277 protocol_negotiated(kProtoUnknown), |
| 277 client_cert_sent(false), | 278 client_cert_sent(false), |
| 278 cert_request_info(NULL), | 279 cert_request_info(NULL), |
| 279 channel_id_sent(false), | 280 channel_id_sent(false), |
| 280 connection_status(0) { | 281 connection_status(0), |
| 282 should_block_on_connect(false), | |
| 283 is_in_session_cache(false) { | |
| 281 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2, | 284 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2, |
| 282 &connection_status); | 285 &connection_status); |
| 283 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 | 286 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 |
| 284 SSLConnectionStatusSetCipherSuite(0xcc14, &connection_status); | 287 SSLConnectionStatusSetCipherSuite(0xcc14, &connection_status); |
| 285 } | 288 } |
| 286 | 289 |
| 287 SSLSocketDataProvider::~SSLSocketDataProvider() { | 290 SSLSocketDataProvider::~SSLSocketDataProvider() { |
| 288 } | 291 } |
| 289 | 292 |
| 290 void SSLSocketDataProvider::SetNextProto(NextProto proto) { | 293 void SSLSocketDataProvider::SetNextProto(NextProto proto) { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 new MockTCPClientSocket(addresses, net_log, data_provider)); | 695 new MockTCPClientSocket(addresses, net_log, data_provider)); |
| 693 data_provider->set_socket(socket.get()); | 696 data_provider->set_socket(socket.get()); |
| 694 return socket.PassAs<StreamSocket>(); | 697 return socket.PassAs<StreamSocket>(); |
| 695 } | 698 } |
| 696 | 699 |
| 697 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( | 700 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( |
| 698 scoped_ptr<ClientSocketHandle> transport_socket, | 701 scoped_ptr<ClientSocketHandle> transport_socket, |
| 699 const HostPortPair& host_and_port, | 702 const HostPortPair& host_and_port, |
| 700 const SSLConfig& ssl_config, | 703 const SSLConfig& ssl_config, |
| 701 const SSLClientSocketContext& context) { | 704 const SSLClientSocketContext& context) { |
| 702 return scoped_ptr<SSLClientSocket>( | 705 scoped_ptr<MockSSLClientSocket> socket( |
| 703 new MockSSLClientSocket(transport_socket.Pass(), | 706 new MockSSLClientSocket(transport_socket.Pass(), |
| 704 host_and_port, ssl_config, | 707 host_and_port, |
| 708 ssl_config, | |
| 705 mock_ssl_data_.GetNext())); | 709 mock_ssl_data_.GetNext())); |
| 710 ssl_client_sockets_.push_back(socket.get()); | |
| 711 return socket.PassAs<SSLClientSocket>(); | |
| 706 } | 712 } |
| 707 | 713 |
| 708 void MockClientSocketFactory::ClearSSLSessionCache() { | 714 void MockClientSocketFactory::ClearSSLSessionCache() { |
| 709 } | 715 } |
| 710 | 716 |
| 711 const char MockClientSocket::kTlsUnique[] = "MOCK_TLSUNIQ"; | 717 const char MockClientSocket::kTlsUnique[] = "MOCK_TLSUNIQ"; |
| 712 | 718 |
| 713 MockClientSocket::MockClientSocket(const BoundNetLog& net_log) | 719 MockClientSocket::MockClientSocket(const BoundNetLog& net_log) |
| 714 : connected_(false), | 720 : connected_(false), |
| 721 reached_connect_(false), | |
| 715 net_log_(net_log), | 722 net_log_(net_log), |
| 716 weak_factory_(this) { | 723 weak_factory_(this) { |
| 717 IPAddressNumber ip; | 724 IPAddressNumber ip; |
| 718 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip)); | 725 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip)); |
| 719 peer_addr_ = IPEndPoint(ip, 0); | 726 peer_addr_ = IPEndPoint(ip, 0); |
| 720 } | 727 } |
| 721 | 728 |
| 722 int MockClientSocket::SetReceiveBufferSize(int32 size) { | 729 int MockClientSocket::SetReceiveBufferSize(int32 size) { |
| 723 return OK; | 730 return OK; |
| 724 } | 731 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 751 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip); | 758 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip); |
| 752 CHECK(rv); | 759 CHECK(rv); |
| 753 *address = IPEndPoint(ip, 123); | 760 *address = IPEndPoint(ip, 123); |
| 754 return OK; | 761 return OK; |
| 755 } | 762 } |
| 756 | 763 |
| 757 const BoundNetLog& MockClientSocket::NetLog() const { | 764 const BoundNetLog& MockClientSocket::NetLog() const { |
| 758 return net_log_; | 765 return net_log_; |
| 759 } | 766 } |
| 760 | 767 |
| 768 bool MockClientSocket::InSessionCache() const { | |
| 769 NOTIMPLEMENTED(); | |
| 770 return false; | |
| 771 } | |
| 772 | |
| 773 void MockClientSocket::SetHandshakeCompletionCallback(const base::Closure& cb) { | |
| 774 NOTIMPLEMENTED(); | |
| 775 } | |
| 776 | |
| 761 void MockClientSocket::GetSSLCertRequestInfo( | 777 void MockClientSocket::GetSSLCertRequestInfo( |
| 762 SSLCertRequestInfo* cert_request_info) { | 778 SSLCertRequestInfo* cert_request_info) { |
| 763 } | 779 } |
| 764 | 780 |
| 765 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, | 781 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, |
| 766 bool has_context, | 782 bool has_context, |
| 767 const base::StringPiece& context, | 783 const base::StringPiece& context, |
| 768 unsigned char* out, | 784 unsigned char* out, |
| 769 unsigned int outlen) { | 785 unsigned int outlen) { |
| 770 memset(out, 'A', outlen); | 786 memset(out, 'A', outlen); |
| 771 return OK; | 787 return OK; |
| 772 } | 788 } |
| 773 | 789 |
| 774 int MockClientSocket::GetTLSUniqueChannelBinding(std::string* out) { | 790 int MockClientSocket::GetTLSUniqueChannelBinding(std::string* out) { |
| 775 out->assign(MockClientSocket::kTlsUnique); | 791 out->assign(MockClientSocket::kTlsUnique); |
| 776 return OK; | 792 return OK; |
| 777 } | 793 } |
| 778 | 794 |
| 779 ServerBoundCertService* MockClientSocket::GetServerBoundCertService() const { | 795 ServerBoundCertService* MockClientSocket::GetServerBoundCertService() const { |
| 780 NOTREACHED(); | 796 NOTREACHED(); |
| 781 return NULL; | 797 return NULL; |
| 782 } | 798 } |
| 783 | 799 |
| 800 bool MockClientSocket::DidReachConnect() const { | |
| 801 return reached_connect_; | |
| 802 } | |
| 803 | |
| 784 SSLClientSocket::NextProtoStatus | 804 SSLClientSocket::NextProtoStatus |
| 785 MockClientSocket::GetNextProto(std::string* proto, std::string* server_protos) { | 805 MockClientSocket::GetNextProto(std::string* proto, std::string* server_protos) { |
| 786 proto->clear(); | 806 proto->clear(); |
| 787 server_protos->clear(); | 807 server_protos->clear(); |
| 788 return SSLClientSocket::kNextProtoUnsupported; | 808 return SSLClientSocket::kNextProtoUnsupported; |
| 789 } | 809 } |
| 790 | 810 |
| 791 scoped_refptr<X509Certificate> | 811 scoped_refptr<X509Certificate> |
| 792 MockClientSocket::GetUnverifiedServerCertificateChain() const { | 812 MockClientSocket::GetUnverifiedServerCertificateChain() const { |
| 793 NOTREACHED(); | 813 NOTREACHED(); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 | 1311 |
| 1292 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1312 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
| 1293 return false; | 1313 return false; |
| 1294 } | 1314 } |
| 1295 | 1315 |
| 1296 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} | 1316 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} |
| 1297 | 1317 |
| 1298 void DeterministicMockTCPClientSocket::OnConnectComplete( | 1318 void DeterministicMockTCPClientSocket::OnConnectComplete( |
| 1299 const MockConnect& data) {} | 1319 const MockConnect& data) {} |
| 1300 | 1320 |
| 1301 // static | |
| 1302 void MockSSLClientSocket::ConnectCallback( | |
| 1303 MockSSLClientSocket* ssl_client_socket, | |
| 1304 const CompletionCallback& callback, | |
| 1305 int rv) { | |
| 1306 if (rv == OK) | |
| 1307 ssl_client_socket->connected_ = true; | |
| 1308 callback.Run(rv); | |
| 1309 } | |
| 1310 | |
| 1311 MockSSLClientSocket::MockSSLClientSocket( | 1321 MockSSLClientSocket::MockSSLClientSocket( |
| 1312 scoped_ptr<ClientSocketHandle> transport_socket, | 1322 scoped_ptr<ClientSocketHandle> transport_socket, |
| 1313 const HostPortPair& host_port_pair, | 1323 const HostPortPair& host_port_pair, |
| 1314 const SSLConfig& ssl_config, | 1324 const SSLConfig& ssl_config, |
| 1315 SSLSocketDataProvider* data) | 1325 SSLSocketDataProvider* data) |
| 1316 : MockClientSocket( | 1326 : MockClientSocket( |
| 1317 // Have to use the right BoundNetLog for LoadTimingInfo regression | 1327 // Have to use the right BoundNetLog for LoadTimingInfo regression |
| 1318 // tests. | 1328 // tests. |
| 1319 transport_socket->socket()->NetLog()), | 1329 transport_socket->socket()->NetLog()), |
| 1320 transport_(transport_socket.Pass()), | 1330 transport_(transport_socket.Pass()), |
| 1321 data_(data), | 1331 data_(data), |
| 1322 is_npn_state_set_(false), | 1332 is_npn_state_set_(false), |
| 1323 new_npn_value_(false), | 1333 new_npn_value_(false), |
| 1324 is_protocol_negotiated_set_(false), | 1334 is_protocol_negotiated_set_(false), |
| 1325 protocol_negotiated_(kProtoUnknown) { | 1335 protocol_negotiated_(kProtoUnknown), |
| 1336 next_connect_state_(STATE_NONE), | |
| 1337 weak_factory_(this) { | |
| 1326 DCHECK(data_); | 1338 DCHECK(data_); |
| 1327 peer_addr_ = data->connect.peer_addr; | 1339 peer_addr_ = data->connect.peer_addr; |
| 1328 } | 1340 } |
| 1329 | 1341 |
| 1330 MockSSLClientSocket::~MockSSLClientSocket() { | 1342 MockSSLClientSocket::~MockSSLClientSocket() { |
| 1331 Disconnect(); | 1343 Disconnect(); |
| 1332 } | 1344 } |
| 1333 | 1345 |
| 1334 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, | 1346 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, |
| 1335 const CompletionCallback& callback) { | 1347 const CompletionCallback& callback) { |
| 1336 return transport_->socket()->Read(buf, buf_len, callback); | 1348 return transport_->socket()->Read(buf, buf_len, callback); |
| 1337 } | 1349 } |
| 1338 | 1350 |
| 1339 int MockSSLClientSocket::Write(IOBuffer* buf, int buf_len, | 1351 int MockSSLClientSocket::Write(IOBuffer* buf, int buf_len, |
| 1340 const CompletionCallback& callback) { | 1352 const CompletionCallback& callback) { |
| 1341 return transport_->socket()->Write(buf, buf_len, callback); | 1353 return transport_->socket()->Write(buf, buf_len, callback); |
| 1342 } | 1354 } |
| 1343 | 1355 |
| 1344 int MockSSLClientSocket::Connect(const CompletionCallback& callback) { | 1356 int MockSSLClientSocket::Connect(const CompletionCallback& callback) { |
| 1345 int rv = transport_->socket()->Connect( | 1357 next_connect_state_ = STATE_TRANSPORT_CONNECT; |
| 1346 base::Bind(&ConnectCallback, base::Unretained(this), callback)); | 1358 int rv = DoConnectLoop(OK); |
| 1347 if (rv == OK) { | 1359 if (rv == ERR_IO_PENDING) |
| 1348 if (data_->connect.result == OK) | 1360 connect_callback_ = callback; |
| 1349 connected_ = true; | |
| 1350 if (data_->connect.mode == ASYNC) { | |
| 1351 RunCallbackAsync(callback, data_->connect.result); | |
| 1352 return ERR_IO_PENDING; | |
| 1353 } | |
| 1354 return data_->connect.result; | |
| 1355 } | |
| 1356 return rv; | 1361 return rv; |
| 1357 } | 1362 } |
| 1358 | 1363 |
| 1359 void MockSSLClientSocket::Disconnect() { | 1364 void MockSSLClientSocket::Disconnect() { |
| 1365 weak_factory_.InvalidateWeakPtrs(); | |
| 1360 MockClientSocket::Disconnect(); | 1366 MockClientSocket::Disconnect(); |
| 1361 if (transport_->socket() != NULL) | 1367 if (transport_->socket() != NULL) |
| 1362 transport_->socket()->Disconnect(); | 1368 transport_->socket()->Disconnect(); |
| 1363 } | 1369 } |
| 1364 | 1370 |
| 1365 bool MockSSLClientSocket::IsConnected() const { | 1371 bool MockSSLClientSocket::IsConnected() const { |
| 1366 return transport_->socket()->IsConnected(); | 1372 return transport_->socket()->IsConnected() && connected_; |
| 1367 } | 1373 } |
| 1368 | 1374 |
| 1369 bool MockSSLClientSocket::WasEverUsed() const { | 1375 bool MockSSLClientSocket::WasEverUsed() const { |
| 1370 return transport_->socket()->WasEverUsed(); | 1376 return transport_->socket()->WasEverUsed(); |
| 1371 } | 1377 } |
| 1372 | 1378 |
| 1373 bool MockSSLClientSocket::UsingTCPFastOpen() const { | 1379 bool MockSSLClientSocket::UsingTCPFastOpen() const { |
| 1374 return transport_->socket()->UsingTCPFastOpen(); | 1380 return transport_->socket()->UsingTCPFastOpen(); |
| 1375 } | 1381 } |
| 1376 | 1382 |
| 1377 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { | 1383 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { |
| 1378 return transport_->socket()->GetPeerAddress(address); | 1384 return transport_->socket()->GetPeerAddress(address); |
| 1379 } | 1385 } |
| 1380 | 1386 |
| 1381 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1387 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
| 1382 ssl_info->Reset(); | 1388 ssl_info->Reset(); |
| 1383 ssl_info->cert = data_->cert; | 1389 ssl_info->cert = data_->cert; |
| 1384 ssl_info->client_cert_sent = data_->client_cert_sent; | 1390 ssl_info->client_cert_sent = data_->client_cert_sent; |
| 1385 ssl_info->channel_id_sent = data_->channel_id_sent; | 1391 ssl_info->channel_id_sent = data_->channel_id_sent; |
| 1386 ssl_info->connection_status = data_->connection_status; | 1392 ssl_info->connection_status = data_->connection_status; |
| 1387 return true; | 1393 return true; |
| 1388 } | 1394 } |
| 1389 | 1395 |
| 1396 bool MockSSLClientSocket::InSessionCache() const { | |
| 1397 return data_->is_in_session_cache; | |
| 1398 } | |
| 1399 | |
| 1400 void MockSSLClientSocket::SetHandshakeCompletionCallback( | |
| 1401 const base::Closure& cb) { | |
| 1402 handshake_completion_callback_ = cb; | |
| 1403 } | |
| 1404 | |
| 1390 void MockSSLClientSocket::GetSSLCertRequestInfo( | 1405 void MockSSLClientSocket::GetSSLCertRequestInfo( |
| 1391 SSLCertRequestInfo* cert_request_info) { | 1406 SSLCertRequestInfo* cert_request_info) { |
| 1392 DCHECK(cert_request_info); | 1407 DCHECK(cert_request_info); |
| 1393 if (data_->cert_request_info) { | 1408 if (data_->cert_request_info) { |
| 1394 cert_request_info->host_and_port = | 1409 cert_request_info->host_and_port = |
| 1395 data_->cert_request_info->host_and_port; | 1410 data_->cert_request_info->host_and_port; |
| 1396 cert_request_info->client_certs = data_->cert_request_info->client_certs; | 1411 cert_request_info->client_certs = data_->cert_request_info->client_certs; |
| 1397 } else { | 1412 } else { |
| 1398 cert_request_info->Reset(); | 1413 cert_request_info->Reset(); |
| 1399 } | 1414 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 } | 1457 } |
| 1443 | 1458 |
| 1444 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { | 1459 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { |
| 1445 NOTIMPLEMENTED(); | 1460 NOTIMPLEMENTED(); |
| 1446 } | 1461 } |
| 1447 | 1462 |
| 1448 void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) { | 1463 void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) { |
| 1449 NOTIMPLEMENTED(); | 1464 NOTIMPLEMENTED(); |
| 1450 } | 1465 } |
| 1451 | 1466 |
| 1467 void MockSSLClientSocket::RestartPausedConnect() { | |
| 1468 DCHECK(data_->should_block_on_connect); | |
| 1469 DCHECK_EQ(next_connect_state_, STATE_SSL_CONNECT_COMPLETE); | |
| 1470 OnIOComplete(data_->connect.result); | |
| 1471 } | |
| 1472 | |
| 1473 void MockSSLClientSocket::OnIOComplete(int result) { | |
| 1474 int rv = DoConnectLoop(result); | |
| 1475 if (rv != ERR_IO_PENDING) { | |
| 1476 base::ResetAndReturn(&connect_callback_).Run(rv); | |
| 1477 } | |
| 1478 } | |
| 1479 | |
| 1480 int MockSSLClientSocket::DoConnectLoop(int result) { | |
| 1481 DCHECK_NE(next_connect_state_, STATE_NONE); | |
| 1482 | |
| 1483 int rv = result; | |
| 1484 do { | |
| 1485 ConnectState state = next_connect_state_; | |
| 1486 next_connect_state_ = STATE_NONE; | |
| 1487 switch (state) { | |
| 1488 case STATE_TRANSPORT_CONNECT: | |
| 1489 rv = DoTransportConnect(); | |
| 1490 break; | |
| 1491 case STATE_TRANSPORT_CONNECT_COMPLETE: | |
| 1492 rv = DoTransportConnectComplete(rv); | |
| 1493 case STATE_SSL_CONNECT: | |
| 1494 rv = DoSSLConnect(); | |
| 1495 break; | |
| 1496 case STATE_SSL_CONNECT_COMPLETE: | |
| 1497 rv = DoSSLConnectComplete(rv); | |
| 1498 break; | |
| 1499 default: | |
| 1500 NOTREACHED() << "bad state"; | |
| 1501 rv = ERR_UNEXPECTED; | |
| 1502 break; | |
| 1503 } | |
| 1504 } while (rv != ERR_IO_PENDING && next_connect_state_ != STATE_NONE); | |
| 1505 | |
| 1506 return rv; | |
| 1507 } | |
| 1508 | |
| 1509 int MockSSLClientSocket::DoTransportConnect() { | |
| 1510 next_connect_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; | |
| 1511 return transport_->socket()->Connect( | |
| 1512 base::Bind(&MockSSLClientSocket::OnIOComplete, base::Unretained(this))); | |
| 1513 } | |
| 1514 | |
| 1515 int MockSSLClientSocket::DoTransportConnectComplete(int result) { | |
| 1516 if (result == OK) | |
| 1517 next_connect_state_ = STATE_SSL_CONNECT; | |
| 1518 return result; | |
| 1519 } | |
| 1520 | |
| 1521 int MockSSLClientSocket::DoSSLConnect() { | |
| 1522 next_connect_state_ = STATE_SSL_CONNECT_COMPLETE; | |
| 1523 | |
| 1524 reached_connect_ = true; | |
|
wtc
2014/07/31 02:02:24
Move this to MockSSLClientSocket::Connect(), at li
mshelley
2014/07/31 20:11:36
Done.
| |
| 1525 | |
| 1526 if (data_->should_block_on_connect) | |
| 1527 return ERR_IO_PENDING; | |
| 1528 | |
| 1529 if (data_->connect.mode == ASYNC) { | |
| 1530 base::MessageLoop::current()->PostTask( | |
| 1531 FROM_HERE, | |
| 1532 base::Bind(&MockSSLClientSocket::OnIOComplete, | |
| 1533 weak_factory_.GetWeakPtr(), | |
| 1534 data_->connect.result)); | |
| 1535 return ERR_IO_PENDING; | |
| 1536 } | |
| 1537 | |
| 1538 return data_->connect.result; | |
| 1539 } | |
| 1540 | |
| 1541 int MockSSLClientSocket::DoSSLConnectComplete(int result) { | |
| 1542 if (data_->connect.result == OK) | |
|
wtc
2014/07/31 02:02:24
data_->connect.result => result
mshelley
2014/07/31 20:11:36
Done.
| |
| 1543 connected_ = true; | |
| 1544 | |
| 1545 if (!handshake_completion_callback_.is_null()) | |
| 1546 base::ResetAndReturn(&handshake_completion_callback_).Run(); | |
| 1547 return result; | |
| 1548 } | |
| 1549 | |
| 1452 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, | 1550 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, |
| 1453 net::NetLog* net_log) | 1551 net::NetLog* net_log) |
| 1454 : connected_(false), | 1552 : connected_(false), |
| 1455 data_(data), | 1553 data_(data), |
| 1456 read_offset_(0), | 1554 read_offset_(0), |
| 1457 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), | 1555 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), |
| 1458 need_read_data_(true), | 1556 need_read_data_(true), |
| 1459 source_port_(123), | 1557 source_port_(123), |
| 1460 pending_buf_(NULL), | 1558 pending_buf_(NULL), |
| 1461 pending_buf_len_(0), | 1559 pending_buf_len_(0), |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1906 | 2004 |
| 1907 const char kSOCKS5OkRequest[] = | 2005 const char kSOCKS5OkRequest[] = |
| 1908 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2006 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 1909 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2007 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 1910 | 2008 |
| 1911 const char kSOCKS5OkResponse[] = | 2009 const char kSOCKS5OkResponse[] = |
| 1912 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2010 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 1913 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2011 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 1914 | 2012 |
| 1915 } // namespace net | 2013 } // namespace net |
| OLD | NEW |