Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: net/socket/socket_test_util.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: REBASE Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 next_ssl_data->next_protos_expected_in_ssl_config.end(), 748 next_ssl_data->next_protos_expected_in_ssl_config.end(),
749 ssl_config.alpn_protos.begin())); 749 ssl_config.alpn_protos.begin()));
750 } 750 }
751 return std::unique_ptr<SSLClientSocket>(new MockSSLClientSocket( 751 return std::unique_ptr<SSLClientSocket>(new MockSSLClientSocket(
752 std::move(transport_socket), host_and_port, ssl_config, next_ssl_data)); 752 std::move(transport_socket), host_and_port, ssl_config, next_ssl_data));
753 } 753 }
754 754
755 void MockClientSocketFactory::ClearSSLSessionCache() { 755 void MockClientSocketFactory::ClearSSLSessionCache() {
756 } 756 }
757 757
758 MockClientSocket::MockClientSocket(const BoundNetLog& net_log) 758 MockClientSocket::MockClientSocket(const NetLogWithSource& net_log)
759 : connected_(false), 759 : connected_(false), net_log_(net_log), weak_factory_(this) {
760 net_log_(net_log),
761 weak_factory_(this) {
762 peer_addr_ = IPEndPoint(IPAddress(192, 0, 2, 33), 0); 760 peer_addr_ = IPEndPoint(IPAddress(192, 0, 2, 33), 0);
763 } 761 }
764 762
765 int MockClientSocket::SetReceiveBufferSize(int32_t size) { 763 int MockClientSocket::SetReceiveBufferSize(int32_t size) {
766 return OK; 764 return OK;
767 } 765 }
768 766
769 int MockClientSocket::SetSendBufferSize(int32_t size) { 767 int MockClientSocket::SetSendBufferSize(int32_t size) {
770 return OK; 768 return OK;
771 } 769 }
(...skipping 15 matching lines...) Expand all
787 return ERR_SOCKET_NOT_CONNECTED; 785 return ERR_SOCKET_NOT_CONNECTED;
788 *address = peer_addr_; 786 *address = peer_addr_;
789 return OK; 787 return OK;
790 } 788 }
791 789
792 int MockClientSocket::GetLocalAddress(IPEndPoint* address) const { 790 int MockClientSocket::GetLocalAddress(IPEndPoint* address) const {
793 *address = IPEndPoint(IPAddress(192, 0, 2, 33), 123); 791 *address = IPEndPoint(IPAddress(192, 0, 2, 33), 123);
794 return OK; 792 return OK;
795 } 793 }
796 794
797 const BoundNetLog& MockClientSocket::NetLog() const { 795 const NetLogWithSource& MockClientSocket::NetLog() const {
798 return net_log_; 796 return net_log_;
799 } 797 }
800 798
801 bool MockClientSocket::WasNpnNegotiated() const { 799 bool MockClientSocket::WasNpnNegotiated() const {
802 return false; 800 return false;
803 } 801 }
804 802
805 NextProto MockClientSocket::GetNegotiatedProtocol() const { 803 NextProto MockClientSocket::GetNegotiatedProtocol() const {
806 return kProtoUnknown; 804 return kProtoUnknown;
807 } 805 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 853
856 void MockClientSocket::RunCallback(const CompletionCallback& callback, 854 void MockClientSocket::RunCallback(const CompletionCallback& callback,
857 int result) { 855 int result) {
858 if (!callback.is_null()) 856 if (!callback.is_null())
859 callback.Run(result); 857 callback.Run(result);
860 } 858 }
861 859
862 MockTCPClientSocket::MockTCPClientSocket(const AddressList& addresses, 860 MockTCPClientSocket::MockTCPClientSocket(const AddressList& addresses,
863 net::NetLog* net_log, 861 net::NetLog* net_log,
864 SocketDataProvider* data) 862 SocketDataProvider* data)
865 : MockClientSocket(BoundNetLog::Make(net_log, NetLogSourceType::NONE)), 863 : MockClientSocket(NetLogWithSource::Make(net_log, NetLogSourceType::NONE)),
866 addresses_(addresses), 864 addresses_(addresses),
867 data_(data), 865 data_(data),
868 read_offset_(0), 866 read_offset_(0),
869 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), 867 read_data_(SYNCHRONOUS, ERR_UNEXPECTED),
870 need_read_data_(true), 868 need_read_data_(true),
871 peer_closed_connection_(false), 869 peer_closed_connection_(false),
872 pending_read_buf_(NULL), 870 pending_read_buf_(NULL),
873 pending_read_buf_len_(0), 871 pending_read_buf_len_(0),
874 was_used_to_convey_data_(false) { 872 was_used_to_convey_data_(false) {
875 DCHECK(data_); 873 DCHECK(data_);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 ssl_client_socket->connected_ = true; 1125 ssl_client_socket->connected_ = true;
1128 callback.Run(rv); 1126 callback.Run(rv);
1129 } 1127 }
1130 1128
1131 MockSSLClientSocket::MockSSLClientSocket( 1129 MockSSLClientSocket::MockSSLClientSocket(
1132 std::unique_ptr<ClientSocketHandle> transport_socket, 1130 std::unique_ptr<ClientSocketHandle> transport_socket,
1133 const HostPortPair& host_port_pair, 1131 const HostPortPair& host_port_pair,
1134 const SSLConfig& ssl_config, 1132 const SSLConfig& ssl_config,
1135 SSLSocketDataProvider* data) 1133 SSLSocketDataProvider* data)
1136 : MockClientSocket( 1134 : MockClientSocket(
1137 // Have to use the right BoundNetLog for LoadTimingInfo regression 1135 // Have to use the right NetLogWithSource for LoadTimingInfo
1136 // regression
1138 // tests. 1137 // tests.
1139 transport_socket->socket()->NetLog()), 1138 transport_socket->socket()->NetLog()),
1140 transport_(std::move(transport_socket)), 1139 transport_(std::move(transport_socket)),
1141 data_(data) { 1140 data_(data) {
1142 DCHECK(data_); 1141 DCHECK(data_);
1143 peer_addr_ = data->connect.peer_addr; 1142 peer_addr_ = data->connect.peer_addr;
1144 } 1143 }
1145 1144
1146 MockSSLClientSocket::~MockSSLClientSocket() { 1145 MockSSLClientSocket::~MockSSLClientSocket() {
1147 Disconnect(); 1146 Disconnect();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 net::NetLog* net_log) 1251 net::NetLog* net_log)
1253 : connected_(false), 1252 : connected_(false),
1254 data_(data), 1253 data_(data),
1255 read_offset_(0), 1254 read_offset_(0),
1256 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), 1255 read_data_(SYNCHRONOUS, ERR_UNEXPECTED),
1257 need_read_data_(true), 1256 need_read_data_(true),
1258 source_port_(123), 1257 source_port_(123),
1259 network_(NetworkChangeNotifier::kInvalidNetworkHandle), 1258 network_(NetworkChangeNotifier::kInvalidNetworkHandle),
1260 pending_read_buf_(NULL), 1259 pending_read_buf_(NULL),
1261 pending_read_buf_len_(0), 1260 pending_read_buf_len_(0),
1262 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::NONE)), 1261 net_log_(NetLogWithSource::Make(net_log, NetLogSourceType::NONE)),
1263 weak_factory_(this) { 1262 weak_factory_(this) {
1264 DCHECK(data_); 1263 DCHECK(data_);
1265 data_->Initialize(this); 1264 data_->Initialize(this);
1266 peer_addr_ = data->connect_data().peer_addr; 1265 peer_addr_ = data->connect_data().peer_addr;
1267 } 1266 }
1268 1267
1269 MockUDPClientSocket::~MockUDPClientSocket() { 1268 MockUDPClientSocket::~MockUDPClientSocket() {
1270 if (data_) 1269 if (data_)
1271 data_->DetachSocket(); 1270 data_->DetachSocket();
1272 } 1271 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 return OK; 1344 return OK;
1346 } 1345 }
1347 1346
1348 int MockUDPClientSocket::GetLocalAddress(IPEndPoint* address) const { 1347 int MockUDPClientSocket::GetLocalAddress(IPEndPoint* address) const {
1349 *address = IPEndPoint(IPAddress(192, 0, 2, 33), source_port_); 1348 *address = IPEndPoint(IPAddress(192, 0, 2, 33), source_port_);
1350 return OK; 1349 return OK;
1351 } 1350 }
1352 1351
1353 void MockUDPClientSocket::UseNonBlockingIO() {} 1352 void MockUDPClientSocket::UseNonBlockingIO() {}
1354 1353
1355 const BoundNetLog& MockUDPClientSocket::NetLog() const { 1354 const NetLogWithSource& MockUDPClientSocket::NetLog() const {
1356 return net_log_; 1355 return net_log_;
1357 } 1356 }
1358 1357
1359 int MockUDPClientSocket::Connect(const IPEndPoint& address) { 1358 int MockUDPClientSocket::Connect(const IPEndPoint& address) {
1360 if (!data_) 1359 if (!data_)
1361 return ERR_UNEXPECTED; 1360 return ERR_UNEXPECTED;
1362 connected_ = true; 1361 connected_ = true;
1363 peer_addr_ = address; 1362 peer_addr_ = address;
1364 return data_->connect_data().result; 1363 return data_->connect_data().result;
1365 } 1364 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 1619
1621 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} 1620 MockTransportClientSocketPool::~MockTransportClientSocketPool() {}
1622 1621
1623 int MockTransportClientSocketPool::RequestSocket( 1622 int MockTransportClientSocketPool::RequestSocket(
1624 const std::string& group_name, 1623 const std::string& group_name,
1625 const void* socket_params, 1624 const void* socket_params,
1626 RequestPriority priority, 1625 RequestPriority priority,
1627 RespectLimits respect_limits, 1626 RespectLimits respect_limits,
1628 ClientSocketHandle* handle, 1627 ClientSocketHandle* handle,
1629 const CompletionCallback& callback, 1628 const CompletionCallback& callback,
1630 const BoundNetLog& net_log) { 1629 const NetLogWithSource& net_log) {
1631 last_request_priority_ = priority; 1630 last_request_priority_ = priority;
1632 std::unique_ptr<StreamSocket> socket = 1631 std::unique_ptr<StreamSocket> socket =
1633 client_socket_factory_->CreateTransportClientSocket( 1632 client_socket_factory_->CreateTransportClientSocket(
1634 AddressList(), NULL, net_log.net_log(), NetLog::Source()); 1633 AddressList(), NULL, net_log.net_log(), NetLog::Source());
1635 MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback); 1634 MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback);
1636 job_list_.push_back(base::WrapUnique(job)); 1635 job_list_.push_back(base::WrapUnique(job));
1637 handle->set_pool_id(1); 1636 handle->set_pool_id(1);
1638 return job->Connect(); 1637 return job->Connect();
1639 } 1638 }
1640 1639
(...skipping 28 matching lines...) Expand all
1669 transport_pool_(transport_pool) {} 1668 transport_pool_(transport_pool) {}
1670 1669
1671 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} 1670 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {}
1672 1671
1673 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, 1672 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name,
1674 const void* socket_params, 1673 const void* socket_params,
1675 RequestPriority priority, 1674 RequestPriority priority,
1676 RespectLimits respect_limits, 1675 RespectLimits respect_limits,
1677 ClientSocketHandle* handle, 1676 ClientSocketHandle* handle,
1678 const CompletionCallback& callback, 1677 const CompletionCallback& callback,
1679 const BoundNetLog& net_log) { 1678 const NetLogWithSource& net_log) {
1680 return transport_pool_->RequestSocket(group_name, socket_params, priority, 1679 return transport_pool_->RequestSocket(group_name, socket_params, priority,
1681 respect_limits, handle, callback, 1680 respect_limits, handle, callback,
1682 net_log); 1681 net_log);
1683 } 1682 }
1684 1683
1685 void MockSOCKSClientSocketPool::CancelRequest( 1684 void MockSOCKSClientSocketPool::CancelRequest(
1686 const std::string& group_name, 1685 const std::string& group_name,
1687 ClientSocketHandle* handle) { 1686 ClientSocketHandle* handle) {
1688 return transport_pool_->CancelRequest(group_name, handle); 1687 return transport_pool_->CancelRequest(group_name, handle);
1689 } 1688 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 } 1731 }
1733 1732
1734 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { 1733 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) {
1735 int64_t total = 0; 1734 int64_t total = 0;
1736 for (const MockWrite* write = writes; write != writes + writes_size; ++write) 1735 for (const MockWrite* write = writes; write != writes + writes_size; ++write)
1737 total += write->data_len; 1736 total += write->data_len;
1738 return total; 1737 return total;
1739 } 1738 }
1740 1739
1741 } // namespace net 1740 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698