| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 new MockUDPClientSocket(data_provider, net_log)); | 721 new MockUDPClientSocket(data_provider, net_log)); |
| 722 if (bind_type == DatagramSocket::RANDOM_BIND) | 722 if (bind_type == DatagramSocket::RANDOM_BIND) |
| 723 socket->set_source_port( | 723 socket->set_source_port( |
| 724 static_cast<uint16_t>(rand_int_cb.Run(1025, 65535))); | 724 static_cast<uint16_t>(rand_int_cb.Run(1025, 65535))); |
| 725 udp_client_socket_ports_.push_back(socket->source_port()); | 725 udp_client_socket_ports_.push_back(socket->source_port()); |
| 726 return std::move(socket); | 726 return std::move(socket); |
| 727 } | 727 } |
| 728 | 728 |
| 729 scoped_ptr<StreamSocket> MockClientSocketFactory::CreateTransportClientSocket( | 729 scoped_ptr<StreamSocket> MockClientSocketFactory::CreateTransportClientSocket( |
| 730 const AddressList& addresses, | 730 const AddressList& addresses, |
| 731 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
| 731 NetLog* net_log, | 732 NetLog* net_log, |
| 732 const NetLog::Source& source) { | 733 const NetLog::Source& source) { |
| 733 SocketDataProvider* data_provider = mock_data_.GetNext(); | 734 SocketDataProvider* data_provider = mock_data_.GetNext(); |
| 734 scoped_ptr<MockTCPClientSocket> socket( | 735 scoped_ptr<MockTCPClientSocket> socket( |
| 735 new MockTCPClientSocket(addresses, net_log, data_provider)); | 736 new MockTCPClientSocket(addresses, net_log, data_provider)); |
| 736 return std::move(socket); | 737 return std::move(socket); |
| 737 } | 738 } |
| 738 | 739 |
| 739 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( | 740 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( |
| 740 scoped_ptr<ClientSocketHandle> transport_socket, | 741 scoped_ptr<ClientSocketHandle> transport_socket, |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 } | 1606 } |
| 1606 | 1607 |
| 1607 MockTransportClientSocketPool::MockTransportClientSocketPool( | 1608 MockTransportClientSocketPool::MockTransportClientSocketPool( |
| 1608 int max_sockets, | 1609 int max_sockets, |
| 1609 int max_sockets_per_group, | 1610 int max_sockets_per_group, |
| 1610 ClientSocketFactory* socket_factory) | 1611 ClientSocketFactory* socket_factory) |
| 1611 : TransportClientSocketPool(max_sockets, | 1612 : TransportClientSocketPool(max_sockets, |
| 1612 max_sockets_per_group, | 1613 max_sockets_per_group, |
| 1613 NULL, | 1614 NULL, |
| 1614 NULL, | 1615 NULL, |
| 1616 NULL, |
| 1615 NULL), | 1617 NULL), |
| 1616 client_socket_factory_(socket_factory), | 1618 client_socket_factory_(socket_factory), |
| 1617 last_request_priority_(DEFAULT_PRIORITY), | 1619 last_request_priority_(DEFAULT_PRIORITY), |
| 1618 release_count_(0), | 1620 release_count_(0), |
| 1619 cancel_count_(0) { | 1621 cancel_count_(0) {} |
| 1620 } | |
| 1621 | 1622 |
| 1622 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} | 1623 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} |
| 1623 | 1624 |
| 1624 int MockTransportClientSocketPool::RequestSocket( | 1625 int MockTransportClientSocketPool::RequestSocket( |
| 1625 const std::string& group_name, | 1626 const std::string& group_name, |
| 1626 const void* socket_params, | 1627 const void* socket_params, |
| 1627 RequestPriority priority, | 1628 RequestPriority priority, |
| 1628 RespectLimits respect_limits, | 1629 RespectLimits respect_limits, |
| 1629 ClientSocketHandle* handle, | 1630 ClientSocketHandle* handle, |
| 1630 const CompletionCallback& callback, | 1631 const CompletionCallback& callback, |
| 1631 const BoundNetLog& net_log) { | 1632 const BoundNetLog& net_log) { |
| 1632 last_request_priority_ = priority; | 1633 last_request_priority_ = priority; |
| 1633 scoped_ptr<StreamSocket> socket = | 1634 scoped_ptr<StreamSocket> socket = |
| 1634 client_socket_factory_->CreateTransportClientSocket( | 1635 client_socket_factory_->CreateTransportClientSocket( |
| 1635 AddressList(), net_log.net_log(), NetLog::Source()); | 1636 AddressList(), NULL, net_log.net_log(), NetLog::Source()); |
| 1636 MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback); | 1637 MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback); |
| 1637 job_list_.push_back(make_scoped_ptr(job)); | 1638 job_list_.push_back(make_scoped_ptr(job)); |
| 1638 handle->set_pool_id(1); | 1639 handle->set_pool_id(1); |
| 1639 return job->Connect(); | 1640 return job->Connect(); |
| 1640 } | 1641 } |
| 1641 | 1642 |
| 1642 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, | 1643 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, |
| 1643 ClientSocketHandle* handle) { | 1644 ClientSocketHandle* handle) { |
| 1644 for (scoped_ptr<MockConnectJob>& it : job_list_) { | 1645 for (scoped_ptr<MockConnectJob>& it : job_list_) { |
| 1645 if (it->CancelHandle(handle)) { | 1646 if (it->CancelHandle(handle)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1658 } | 1659 } |
| 1659 | 1660 |
| 1660 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( | 1661 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( |
| 1661 int max_sockets, | 1662 int max_sockets, |
| 1662 int max_sockets_per_group, | 1663 int max_sockets_per_group, |
| 1663 TransportClientSocketPool* transport_pool) | 1664 TransportClientSocketPool* transport_pool) |
| 1664 : SOCKSClientSocketPool(max_sockets, | 1665 : SOCKSClientSocketPool(max_sockets, |
| 1665 max_sockets_per_group, | 1666 max_sockets_per_group, |
| 1666 NULL, | 1667 NULL, |
| 1667 transport_pool, | 1668 transport_pool, |
| 1669 NULL, |
| 1668 NULL), | 1670 NULL), |
| 1669 transport_pool_(transport_pool) { | 1671 transport_pool_(transport_pool) {} |
| 1670 } | |
| 1671 | 1672 |
| 1672 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} | 1673 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} |
| 1673 | 1674 |
| 1674 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, | 1675 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, |
| 1675 const void* socket_params, | 1676 const void* socket_params, |
| 1676 RequestPriority priority, | 1677 RequestPriority priority, |
| 1677 RespectLimits respect_limits, | 1678 RespectLimits respect_limits, |
| 1678 ClientSocketHandle* handle, | 1679 ClientSocketHandle* handle, |
| 1679 const CompletionCallback& callback, | 1680 const CompletionCallback& callback, |
| 1680 const BoundNetLog& net_log) { | 1681 const BoundNetLog& net_log) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 } | 1733 } |
| 1733 | 1734 |
| 1734 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { | 1735 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { |
| 1735 int64_t total = 0; | 1736 int64_t total = 0; |
| 1736 for (const MockWrite* write = writes; write != writes + writes_size; ++write) | 1737 for (const MockWrite* write = writes; write != writes + writes_size; ++write) |
| 1737 total += write->data_len; | 1738 total += write->data_len; |
| 1738 return total; | 1739 return total; |
| 1739 } | 1740 } |
| 1740 | 1741 |
| 1741 } // namespace net | 1742 } // namespace net |
| OLD | NEW |