| 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 new MockUDPClientSocket(data_provider, net_log)); | 709 new MockUDPClientSocket(data_provider, net_log)); |
| 710 if (bind_type == DatagramSocket::RANDOM_BIND) | 710 if (bind_type == DatagramSocket::RANDOM_BIND) |
| 711 socket->set_source_port( | 711 socket->set_source_port( |
| 712 static_cast<uint16_t>(rand_int_cb.Run(1025, 65535))); | 712 static_cast<uint16_t>(rand_int_cb.Run(1025, 65535))); |
| 713 udp_client_socket_ports_.push_back(socket->source_port()); | 713 udp_client_socket_ports_.push_back(socket->source_port()); |
| 714 return std::move(socket); | 714 return std::move(socket); |
| 715 } | 715 } |
| 716 | 716 |
| 717 scoped_ptr<StreamSocket> MockClientSocketFactory::CreateTransportClientSocket( | 717 scoped_ptr<StreamSocket> MockClientSocketFactory::CreateTransportClientSocket( |
| 718 const AddressList& addresses, | 718 const AddressList& addresses, |
| 719 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, |
| 719 NetLog* net_log, | 720 NetLog* net_log, |
| 720 const NetLog::Source& source) { | 721 const NetLog::Source& source) { |
| 721 SocketDataProvider* data_provider = mock_data_.GetNext(); | 722 SocketDataProvider* data_provider = mock_data_.GetNext(); |
| 722 scoped_ptr<MockTCPClientSocket> socket( | 723 scoped_ptr<MockTCPClientSocket> socket( |
| 723 new MockTCPClientSocket(addresses, net_log, data_provider)); | 724 new MockTCPClientSocket(addresses, net_log, data_provider)); |
| 724 return std::move(socket); | 725 return std::move(socket); |
| 725 } | 726 } |
| 726 | 727 |
| 727 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( | 728 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( |
| 728 scoped_ptr<ClientSocketHandle> transport_socket, | 729 scoped_ptr<ClientSocketHandle> transport_socket, |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 } | 1600 } |
| 1600 | 1601 |
| 1601 MockTransportClientSocketPool::MockTransportClientSocketPool( | 1602 MockTransportClientSocketPool::MockTransportClientSocketPool( |
| 1602 int max_sockets, | 1603 int max_sockets, |
| 1603 int max_sockets_per_group, | 1604 int max_sockets_per_group, |
| 1604 ClientSocketFactory* socket_factory) | 1605 ClientSocketFactory* socket_factory) |
| 1605 : TransportClientSocketPool(max_sockets, | 1606 : TransportClientSocketPool(max_sockets, |
| 1606 max_sockets_per_group, | 1607 max_sockets_per_group, |
| 1607 NULL, | 1608 NULL, |
| 1608 NULL, | 1609 NULL, |
| 1610 NULL, |
| 1609 NULL), | 1611 NULL), |
| 1610 client_socket_factory_(socket_factory), | 1612 client_socket_factory_(socket_factory), |
| 1611 last_request_priority_(DEFAULT_PRIORITY), | 1613 last_request_priority_(DEFAULT_PRIORITY), |
| 1612 release_count_(0), | 1614 release_count_(0), |
| 1613 cancel_count_(0) { | 1615 cancel_count_(0) {} |
| 1614 } | |
| 1615 | 1616 |
| 1616 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} | 1617 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} |
| 1617 | 1618 |
| 1618 int MockTransportClientSocketPool::RequestSocket( | 1619 int MockTransportClientSocketPool::RequestSocket( |
| 1619 const std::string& group_name, | 1620 const std::string& group_name, |
| 1620 const void* socket_params, | 1621 const void* socket_params, |
| 1621 RequestPriority priority, | 1622 RequestPriority priority, |
| 1622 RespectLimits respect_limits, | 1623 RespectLimits respect_limits, |
| 1623 ClientSocketHandle* handle, | 1624 ClientSocketHandle* handle, |
| 1624 const CompletionCallback& callback, | 1625 const CompletionCallback& callback, |
| 1625 const BoundNetLog& net_log) { | 1626 const BoundNetLog& net_log) { |
| 1626 last_request_priority_ = priority; | 1627 last_request_priority_ = priority; |
| 1627 scoped_ptr<StreamSocket> socket = | 1628 scoped_ptr<StreamSocket> socket = |
| 1628 client_socket_factory_->CreateTransportClientSocket( | 1629 client_socket_factory_->CreateTransportClientSocket( |
| 1629 AddressList(), net_log.net_log(), NetLog::Source()); | 1630 AddressList(), NULL, net_log.net_log(), NetLog::Source()); |
| 1630 MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback); | 1631 MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback); |
| 1631 job_list_.push_back(make_scoped_ptr(job)); | 1632 job_list_.push_back(make_scoped_ptr(job)); |
| 1632 handle->set_pool_id(1); | 1633 handle->set_pool_id(1); |
| 1633 return job->Connect(); | 1634 return job->Connect(); |
| 1634 } | 1635 } |
| 1635 | 1636 |
| 1636 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, | 1637 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, |
| 1637 ClientSocketHandle* handle) { | 1638 ClientSocketHandle* handle) { |
| 1638 for (scoped_ptr<MockConnectJob>& it : job_list_) { | 1639 for (scoped_ptr<MockConnectJob>& it : job_list_) { |
| 1639 if (it->CancelHandle(handle)) { | 1640 if (it->CancelHandle(handle)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1652 } | 1653 } |
| 1653 | 1654 |
| 1654 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( | 1655 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( |
| 1655 int max_sockets, | 1656 int max_sockets, |
| 1656 int max_sockets_per_group, | 1657 int max_sockets_per_group, |
| 1657 TransportClientSocketPool* transport_pool) | 1658 TransportClientSocketPool* transport_pool) |
| 1658 : SOCKSClientSocketPool(max_sockets, | 1659 : SOCKSClientSocketPool(max_sockets, |
| 1659 max_sockets_per_group, | 1660 max_sockets_per_group, |
| 1660 NULL, | 1661 NULL, |
| 1661 transport_pool, | 1662 transport_pool, |
| 1663 NULL, |
| 1662 NULL), | 1664 NULL), |
| 1663 transport_pool_(transport_pool) { | 1665 transport_pool_(transport_pool) {} |
| 1664 } | |
| 1665 | 1666 |
| 1666 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} | 1667 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} |
| 1667 | 1668 |
| 1668 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, | 1669 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, |
| 1669 const void* socket_params, | 1670 const void* socket_params, |
| 1670 RequestPriority priority, | 1671 RequestPriority priority, |
| 1671 RespectLimits respect_limits, | 1672 RespectLimits respect_limits, |
| 1672 ClientSocketHandle* handle, | 1673 ClientSocketHandle* handle, |
| 1673 const CompletionCallback& callback, | 1674 const CompletionCallback& callback, |
| 1674 const BoundNetLog& net_log) { | 1675 const BoundNetLog& net_log) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 } | 1727 } |
| 1727 | 1728 |
| 1728 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { | 1729 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { |
| 1729 int64_t total = 0; | 1730 int64_t total = 0; |
| 1730 for (const MockWrite* write = writes; write != writes + writes_size; ++write) | 1731 for (const MockWrite* write = writes; write != writes + writes_size; ++write) |
| 1731 total += write->data_len; | 1732 total += write->data_len; |
| 1732 return total; | 1733 return total; |
| 1733 } | 1734 } |
| 1734 | 1735 |
| 1735 } // namespace net | 1736 } // namespace net |
| OLD | NEW |