| 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 mock_data_.ResetNextIndex(); | 656 mock_data_.ResetNextIndex(); |
| 657 mock_ssl_data_.ResetNextIndex(); | 657 mock_ssl_data_.ResetNextIndex(); |
| 658 } | 658 } |
| 659 | 659 |
| 660 scoped_ptr<DatagramClientSocket> | 660 scoped_ptr<DatagramClientSocket> |
| 661 MockClientSocketFactory::CreateDatagramClientSocket( | 661 MockClientSocketFactory::CreateDatagramClientSocket( |
| 662 DatagramSocket::BindType bind_type, | 662 DatagramSocket::BindType bind_type, |
| 663 const RandIntCallback& rand_int_cb, | 663 const RandIntCallback& rand_int_cb, |
| 664 net::NetLog* net_log, | 664 net::NetLog* net_log, |
| 665 const net::NetLog::Source& source) { | 665 const net::NetLog::Source& source) { |
| 666 // Socket connect is supposed to call for some random suggestions for ports. |
| 667 // We call 3 times so that the quic_stream_factory will know this function |
| 668 // was consulted (it has a DCHECK), but will not actually DCHECK the |
| 669 // resulting ephemeral port (which we don't set). |
| 670 for (int count = 3; count > 0; --count) |
| 671 rand_int_cb.Run(1000, 2000); |
| 666 SocketDataProvider* data_provider = mock_data_.GetNext(); | 672 SocketDataProvider* data_provider = mock_data_.GetNext(); |
| 667 scoped_ptr<MockUDPClientSocket> socket( | 673 scoped_ptr<MockUDPClientSocket> socket( |
| 668 new MockUDPClientSocket(data_provider, net_log)); | 674 new MockUDPClientSocket(data_provider, net_log)); |
| 669 data_provider->set_socket(socket.get()); | 675 data_provider->set_socket(socket.get()); |
| 670 return socket.PassAs<DatagramClientSocket>(); | 676 return socket.PassAs<DatagramClientSocket>(); |
| 671 } | 677 } |
| 672 | 678 |
| 673 scoped_ptr<StreamSocket> MockClientSocketFactory::CreateTransportClientSocket( | 679 scoped_ptr<StreamSocket> MockClientSocketFactory::CreateTransportClientSocket( |
| 674 const AddressList& addresses, | 680 const AddressList& addresses, |
| 675 net::NetLog* net_log, | 681 net::NetLog* net_log, |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 DCHECK_LT(index, ssl_client_sockets_.size()); | 1802 DCHECK_LT(index, ssl_client_sockets_.size()); |
| 1797 return ssl_client_sockets_[index]; | 1803 return ssl_client_sockets_[index]; |
| 1798 } | 1804 } |
| 1799 | 1805 |
| 1800 scoped_ptr<DatagramClientSocket> | 1806 scoped_ptr<DatagramClientSocket> |
| 1801 DeterministicMockClientSocketFactory::CreateDatagramClientSocket( | 1807 DeterministicMockClientSocketFactory::CreateDatagramClientSocket( |
| 1802 DatagramSocket::BindType bind_type, | 1808 DatagramSocket::BindType bind_type, |
| 1803 const RandIntCallback& rand_int_cb, | 1809 const RandIntCallback& rand_int_cb, |
| 1804 net::NetLog* net_log, | 1810 net::NetLog* net_log, |
| 1805 const NetLog::Source& source) { | 1811 const NetLog::Source& source) { |
| 1812 // Socket connect is supposed to call for some random suggestions for ports. |
| 1813 // We call 3 times so that the quic_stream_factory will know this function |
| 1814 // was consulted (it has a DCHECK), but will not actually DCHECK the |
| 1815 // resulting ephemeral port (which we don't set). |
| 1816 for (int count = 3; count > 0; --count) |
| 1817 rand_int_cb.Run(1000, 2000); |
| 1806 DeterministicSocketData* data_provider = mock_data().GetNext(); | 1818 DeterministicSocketData* data_provider = mock_data().GetNext(); |
| 1807 scoped_ptr<DeterministicMockUDPClientSocket> socket( | 1819 scoped_ptr<DeterministicMockUDPClientSocket> socket( |
| 1808 new DeterministicMockUDPClientSocket(net_log, data_provider)); | 1820 new DeterministicMockUDPClientSocket(net_log, data_provider)); |
| 1809 data_provider->set_delegate(socket->AsWeakPtr()); | 1821 data_provider->set_delegate(socket->AsWeakPtr()); |
| 1810 udp_client_sockets().push_back(socket.get()); | 1822 udp_client_sockets().push_back(socket.get()); |
| 1811 return socket.PassAs<DatagramClientSocket>(); | 1823 return socket.PassAs<DatagramClientSocket>(); |
| 1812 } | 1824 } |
| 1813 | 1825 |
| 1814 scoped_ptr<StreamSocket> | 1826 scoped_ptr<StreamSocket> |
| 1815 DeterministicMockClientSocketFactory::CreateTransportClientSocket( | 1827 DeterministicMockClientSocketFactory::CreateTransportClientSocket( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 | 1893 |
| 1882 const char kSOCKS5OkRequest[] = | 1894 const char kSOCKS5OkRequest[] = |
| 1883 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1895 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 1884 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1896 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 1885 | 1897 |
| 1886 const char kSOCKS5OkResponse[] = | 1898 const char kSOCKS5OkResponse[] = |
| 1887 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1899 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 1888 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1900 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 1889 | 1901 |
| 1890 } // namespace net | 1902 } // namespace net |
| OLD | NEW |