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 ChannelIDService* MockClientSocket::GetChannelIDService() const { | 795 ChannelIDService* MockClientSocket::GetChannelIDService() const { |
780 NOTREACHED(); | 796 NOTREACHED(); |
781 return NULL; | 797 return NULL; |
782 } | 798 } |
783 | 799 |
784 SSLClientSocket::NextProtoStatus | 800 SSLClientSocket::NextProtoStatus MockClientSocket::GetNextProto( |
785 MockClientSocket::GetNextProto(std::string* proto) { | 801 std::string* proto, |
802 std::string* server_protos) { | |
wtc
2014/07/31 23:05:24
IMPORTANT: is this part of the CL?
mshelley
2014/08/02 23:59:14
Done.
| |
786 proto->clear(); | 803 proto->clear(); |
787 return SSLClientSocket::kNextProtoUnsupported; | 804 return SSLClientSocket::kNextProtoUnsupported; |
788 } | 805 } |
789 | 806 |
790 scoped_refptr<X509Certificate> | 807 scoped_refptr<X509Certificate> |
791 MockClientSocket::GetUnverifiedServerCertificateChain() const { | 808 MockClientSocket::GetUnverifiedServerCertificateChain() const { |
792 NOTREACHED(); | 809 NOTREACHED(); |
793 return NULL; | 810 return NULL; |
794 } | 811 } |
795 | 812 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1290 | 1307 |
1291 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1308 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
1292 return false; | 1309 return false; |
1293 } | 1310 } |
1294 | 1311 |
1295 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} | 1312 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} |
1296 | 1313 |
1297 void DeterministicMockTCPClientSocket::OnConnectComplete( | 1314 void DeterministicMockTCPClientSocket::OnConnectComplete( |
1298 const MockConnect& data) {} | 1315 const MockConnect& data) {} |
1299 | 1316 |
1300 // static | |
1301 void MockSSLClientSocket::ConnectCallback( | |
1302 MockSSLClientSocket* ssl_client_socket, | |
1303 const CompletionCallback& callback, | |
1304 int rv) { | |
1305 if (rv == OK) | |
1306 ssl_client_socket->connected_ = true; | |
1307 callback.Run(rv); | |
1308 } | |
1309 | |
1310 MockSSLClientSocket::MockSSLClientSocket( | 1317 MockSSLClientSocket::MockSSLClientSocket( |
1311 scoped_ptr<ClientSocketHandle> transport_socket, | 1318 scoped_ptr<ClientSocketHandle> transport_socket, |
1312 const HostPortPair& host_port_pair, | 1319 const HostPortPair& host_port_pair, |
1313 const SSLConfig& ssl_config, | 1320 const SSLConfig& ssl_config, |
1314 SSLSocketDataProvider* data) | 1321 SSLSocketDataProvider* data) |
1315 : MockClientSocket( | 1322 : MockClientSocket( |
1316 // Have to use the right BoundNetLog for LoadTimingInfo regression | 1323 // Have to use the right BoundNetLog for LoadTimingInfo regression |
1317 // tests. | 1324 // tests. |
1318 transport_socket->socket()->NetLog()), | 1325 transport_socket->socket()->NetLog()), |
1319 transport_(transport_socket.Pass()), | 1326 transport_(transport_socket.Pass()), |
1320 data_(data), | 1327 data_(data), |
1321 is_npn_state_set_(false), | 1328 is_npn_state_set_(false), |
1322 new_npn_value_(false), | 1329 new_npn_value_(false), |
1323 is_protocol_negotiated_set_(false), | 1330 is_protocol_negotiated_set_(false), |
1324 protocol_negotiated_(kProtoUnknown) { | 1331 protocol_negotiated_(kProtoUnknown), |
1332 next_connect_state_(STATE_NONE), | |
1333 weak_factory_(this) { | |
1325 DCHECK(data_); | 1334 DCHECK(data_); |
1326 peer_addr_ = data->connect.peer_addr; | 1335 peer_addr_ = data->connect.peer_addr; |
1327 } | 1336 } |
1328 | 1337 |
1329 MockSSLClientSocket::~MockSSLClientSocket() { | 1338 MockSSLClientSocket::~MockSSLClientSocket() { |
1330 Disconnect(); | 1339 Disconnect(); |
1331 } | 1340 } |
1332 | 1341 |
1333 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, | 1342 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, |
1334 const CompletionCallback& callback) { | 1343 const CompletionCallback& callback) { |
1335 return transport_->socket()->Read(buf, buf_len, callback); | 1344 return transport_->socket()->Read(buf, buf_len, callback); |
1336 } | 1345 } |
1337 | 1346 |
1338 int MockSSLClientSocket::Write(IOBuffer* buf, int buf_len, | 1347 int MockSSLClientSocket::Write(IOBuffer* buf, int buf_len, |
1339 const CompletionCallback& callback) { | 1348 const CompletionCallback& callback) { |
1340 return transport_->socket()->Write(buf, buf_len, callback); | 1349 return transport_->socket()->Write(buf, buf_len, callback); |
1341 } | 1350 } |
1342 | 1351 |
1343 int MockSSLClientSocket::Connect(const CompletionCallback& callback) { | 1352 int MockSSLClientSocket::Connect(const CompletionCallback& callback) { |
1344 int rv = transport_->socket()->Connect( | 1353 next_connect_state_ = STATE_TRANSPORT_CONNECT; |
1345 base::Bind(&ConnectCallback, base::Unretained(this), callback)); | 1354 reached_connect_ = true; |
1346 if (rv == OK) { | 1355 int rv = DoConnectLoop(OK); |
1347 if (data_->connect.result == OK) | 1356 if (rv == ERR_IO_PENDING) |
1348 connected_ = true; | 1357 connect_callback_ = callback; |
1349 if (data_->connect.mode == ASYNC) { | |
1350 RunCallbackAsync(callback, data_->connect.result); | |
1351 return ERR_IO_PENDING; | |
1352 } | |
1353 return data_->connect.result; | |
1354 } | |
1355 return rv; | 1358 return rv; |
1356 } | 1359 } |
1357 | 1360 |
1358 void MockSSLClientSocket::Disconnect() { | 1361 void MockSSLClientSocket::Disconnect() { |
1362 weak_factory_.InvalidateWeakPtrs(); | |
1359 MockClientSocket::Disconnect(); | 1363 MockClientSocket::Disconnect(); |
1360 if (transport_->socket() != NULL) | 1364 if (transport_->socket() != NULL) |
1361 transport_->socket()->Disconnect(); | 1365 transport_->socket()->Disconnect(); |
1362 } | 1366 } |
1363 | 1367 |
1364 bool MockSSLClientSocket::IsConnected() const { | 1368 bool MockSSLClientSocket::IsConnected() const { |
1365 return transport_->socket()->IsConnected(); | 1369 return transport_->socket()->IsConnected() && connected_; |
1366 } | 1370 } |
1367 | 1371 |
1368 bool MockSSLClientSocket::WasEverUsed() const { | 1372 bool MockSSLClientSocket::WasEverUsed() const { |
1369 return transport_->socket()->WasEverUsed(); | 1373 return transport_->socket()->WasEverUsed(); |
1370 } | 1374 } |
1371 | 1375 |
1372 bool MockSSLClientSocket::UsingTCPFastOpen() const { | 1376 bool MockSSLClientSocket::UsingTCPFastOpen() const { |
1373 return transport_->socket()->UsingTCPFastOpen(); | 1377 return transport_->socket()->UsingTCPFastOpen(); |
1374 } | 1378 } |
1375 | 1379 |
1376 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { | 1380 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { |
1377 return transport_->socket()->GetPeerAddress(address); | 1381 return transport_->socket()->GetPeerAddress(address); |
1378 } | 1382 } |
1379 | 1383 |
1380 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 1384 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
1381 ssl_info->Reset(); | 1385 ssl_info->Reset(); |
1382 ssl_info->cert = data_->cert; | 1386 ssl_info->cert = data_->cert; |
1383 ssl_info->client_cert_sent = data_->client_cert_sent; | 1387 ssl_info->client_cert_sent = data_->client_cert_sent; |
1384 ssl_info->channel_id_sent = data_->channel_id_sent; | 1388 ssl_info->channel_id_sent = data_->channel_id_sent; |
1385 ssl_info->connection_status = data_->connection_status; | 1389 ssl_info->connection_status = data_->connection_status; |
1386 return true; | 1390 return true; |
1387 } | 1391 } |
1388 | 1392 |
1393 bool MockSSLClientSocket::InSessionCache() const { | |
1394 return data_->is_in_session_cache; | |
1395 } | |
1396 | |
1397 void MockSSLClientSocket::SetHandshakeCompletionCallback( | |
1398 const base::Closure& cb) { | |
1399 handshake_completion_callback_ = cb; | |
1400 } | |
1401 | |
1389 void MockSSLClientSocket::GetSSLCertRequestInfo( | 1402 void MockSSLClientSocket::GetSSLCertRequestInfo( |
1390 SSLCertRequestInfo* cert_request_info) { | 1403 SSLCertRequestInfo* cert_request_info) { |
1391 DCHECK(cert_request_info); | 1404 DCHECK(cert_request_info); |
1392 if (data_->cert_request_info) { | 1405 if (data_->cert_request_info) { |
1393 cert_request_info->host_and_port = | 1406 cert_request_info->host_and_port = |
1394 data_->cert_request_info->host_and_port; | 1407 data_->cert_request_info->host_and_port; |
1395 cert_request_info->client_certs = data_->cert_request_info->client_certs; | 1408 cert_request_info->client_certs = data_->cert_request_info->client_certs; |
1396 } else { | 1409 } else { |
1397 cert_request_info->Reset(); | 1410 cert_request_info->Reset(); |
1398 } | 1411 } |
1399 } | 1412 } |
1400 | 1413 |
1401 SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( | 1414 SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( |
1402 std::string* proto) { | 1415 std::string* proto, |
1416 std::string* server_protos) { | |
wtc
2014/07/31 23:05:24
IMPORTANT: is this part of the CL?
mshelley
2014/08/02 23:59:14
Done.
| |
1403 *proto = data_->next_proto; | 1417 *proto = data_->next_proto; |
1404 return data_->next_proto_status; | 1418 return data_->next_proto_status; |
1405 } | 1419 } |
1406 | 1420 |
1407 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { | 1421 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { |
1408 is_npn_state_set_ = true; | 1422 is_npn_state_set_ = true; |
1409 return new_npn_value_ = negotiated; | 1423 return new_npn_value_ = negotiated; |
1410 } | 1424 } |
1411 | 1425 |
1412 bool MockSSLClientSocket::WasNpnNegotiated() const { | 1426 bool MockSSLClientSocket::WasNpnNegotiated() const { |
(...skipping 27 matching lines...) Expand all Loading... | |
1440 } | 1454 } |
1441 | 1455 |
1442 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { | 1456 void MockSSLClientSocket::OnReadComplete(const MockRead& data) { |
1443 NOTIMPLEMENTED(); | 1457 NOTIMPLEMENTED(); |
1444 } | 1458 } |
1445 | 1459 |
1446 void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) { | 1460 void MockSSLClientSocket::OnConnectComplete(const MockConnect& data) { |
1447 NOTIMPLEMENTED(); | 1461 NOTIMPLEMENTED(); |
1448 } | 1462 } |
1449 | 1463 |
1464 void MockSSLClientSocket::RestartPausedConnect() { | |
1465 DCHECK(data_->should_block_on_connect); | |
1466 DCHECK_EQ(next_connect_state_, STATE_SSL_CONNECT_COMPLETE); | |
1467 OnIOComplete(data_->connect.result); | |
1468 } | |
1469 | |
1470 void MockSSLClientSocket::OnIOComplete(int result) { | |
1471 int rv = DoConnectLoop(result); | |
1472 if (rv != ERR_IO_PENDING) { | |
1473 base::ResetAndReturn(&connect_callback_).Run(rv); | |
1474 } | |
wtc
2014/07/31 23:05:24
Nit: omit curly braces.
mshelley
2014/08/02 23:59:14
Done.
| |
1475 } | |
1476 | |
1477 int MockSSLClientSocket::DoConnectLoop(int result) { | |
1478 DCHECK_NE(next_connect_state_, STATE_NONE); | |
1479 | |
1480 int rv = result; | |
1481 do { | |
1482 ConnectState state = next_connect_state_; | |
1483 next_connect_state_ = STATE_NONE; | |
1484 switch (state) { | |
1485 case STATE_TRANSPORT_CONNECT: | |
1486 rv = DoTransportConnect(); | |
1487 break; | |
1488 case STATE_TRANSPORT_CONNECT_COMPLETE: | |
1489 rv = DoTransportConnectComplete(rv); | |
wtc
2014/07/31 23:05:24
BUG: add a break statement after this line.
mshelley
2014/08/02 23:59:14
Done.
| |
1490 case STATE_SSL_CONNECT: | |
1491 rv = DoSSLConnect(); | |
1492 break; | |
1493 case STATE_SSL_CONNECT_COMPLETE: | |
1494 rv = DoSSLConnectComplete(rv); | |
1495 break; | |
1496 default: | |
1497 NOTREACHED() << "bad state"; | |
1498 rv = ERR_UNEXPECTED; | |
1499 break; | |
1500 } | |
1501 } while (rv != ERR_IO_PENDING && next_connect_state_ != STATE_NONE); | |
1502 | |
1503 return rv; | |
1504 } | |
1505 | |
1506 int MockSSLClientSocket::DoTransportConnect() { | |
1507 next_connect_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; | |
1508 return transport_->socket()->Connect( | |
1509 base::Bind(&MockSSLClientSocket::OnIOComplete, base::Unretained(this))); | |
1510 } | |
1511 | |
1512 int MockSSLClientSocket::DoTransportConnectComplete(int result) { | |
1513 if (result == OK) | |
1514 next_connect_state_ = STATE_SSL_CONNECT; | |
1515 return result; | |
1516 } | |
1517 | |
1518 int MockSSLClientSocket::DoSSLConnect() { | |
1519 next_connect_state_ = STATE_SSL_CONNECT_COMPLETE; | |
1520 | |
1521 if (data_->should_block_on_connect) | |
1522 return ERR_IO_PENDING; | |
1523 | |
1524 if (data_->connect.mode == ASYNC) { | |
1525 base::MessageLoop::current()->PostTask( | |
1526 FROM_HERE, | |
1527 base::Bind(&MockSSLClientSocket::OnIOComplete, | |
1528 weak_factory_.GetWeakPtr(), | |
1529 data_->connect.result)); | |
1530 return ERR_IO_PENDING; | |
1531 } | |
1532 | |
1533 return data_->connect.result; | |
1534 } | |
1535 | |
1536 int MockSSLClientSocket::DoSSLConnectComplete(int result) { | |
1537 if (result == OK) | |
1538 connected_ = true; | |
1539 | |
1540 if (!handshake_completion_callback_.is_null()) | |
1541 base::ResetAndReturn(&handshake_completion_callback_).Run(); | |
1542 return result; | |
1543 } | |
1544 | |
1450 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, | 1545 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, |
1451 net::NetLog* net_log) | 1546 net::NetLog* net_log) |
1452 : connected_(false), | 1547 : connected_(false), |
1453 data_(data), | 1548 data_(data), |
1454 read_offset_(0), | 1549 read_offset_(0), |
1455 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), | 1550 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), |
1456 need_read_data_(true), | 1551 need_read_data_(true), |
1457 source_port_(123), | 1552 source_port_(123), |
1458 pending_buf_(NULL), | 1553 pending_buf_(NULL), |
1459 pending_buf_len_(0), | 1554 pending_buf_len_(0), |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1904 | 1999 |
1905 const char kSOCKS5OkRequest[] = | 2000 const char kSOCKS5OkRequest[] = |
1906 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2001 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1907 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2002 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1908 | 2003 |
1909 const char kSOCKS5OkResponse[] = | 2004 const char kSOCKS5OkResponse[] = |
1910 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2005 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1911 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2006 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1912 | 2007 |
1913 } // namespace net | 2008 } // namespace net |
OLD | NEW |