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

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

Issue 12886034: Remove experimental code to pick the "warmest" socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Don't add missing include (Shouldn't be done in this CL) Created 7 years, 8 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 | Annotate | Revision Log
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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 callback.Run(result); 784 callback.Run(result);
785 } 785 }
786 786
787 MockTCPClientSocket::MockTCPClientSocket(const AddressList& addresses, 787 MockTCPClientSocket::MockTCPClientSocket(const AddressList& addresses,
788 net::NetLog* net_log, 788 net::NetLog* net_log,
789 SocketDataProvider* data) 789 SocketDataProvider* data)
790 : MockClientSocket(BoundNetLog::Make(net_log, net::NetLog::SOURCE_NONE)), 790 : MockClientSocket(BoundNetLog::Make(net_log, net::NetLog::SOURCE_NONE)),
791 addresses_(addresses), 791 addresses_(addresses),
792 data_(data), 792 data_(data),
793 read_offset_(0), 793 read_offset_(0),
794 num_bytes_read_(0),
795 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), 794 read_data_(SYNCHRONOUS, ERR_UNEXPECTED),
796 need_read_data_(true), 795 need_read_data_(true),
797 peer_closed_connection_(false), 796 peer_closed_connection_(false),
798 pending_buf_(NULL), 797 pending_buf_(NULL),
799 pending_buf_len_(0), 798 pending_buf_len_(0),
800 was_used_to_convey_data_(false) { 799 was_used_to_convey_data_(false) {
801 DCHECK(data_); 800 DCHECK(data_);
802 peer_addr_ = data->connect_data().peer_addr; 801 peer_addr_ = data->connect_data().peer_addr;
803 data_->Reset(); 802 data_->Reset();
804 } 803 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 893 }
895 894
896 bool MockTCPClientSocket::WasEverUsed() const { 895 bool MockTCPClientSocket::WasEverUsed() const {
897 return was_used_to_convey_data_; 896 return was_used_to_convey_data_;
898 } 897 }
899 898
900 bool MockTCPClientSocket::UsingTCPFastOpen() const { 899 bool MockTCPClientSocket::UsingTCPFastOpen() const {
901 return false; 900 return false;
902 } 901 }
903 902
904 int64 MockTCPClientSocket::NumBytesRead() const {
905 return num_bytes_read_;
906 }
907
908 base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const {
909 // Dummy value.
910 static const base::TimeDelta kTestingConnectTimeMicros =
911 base::TimeDelta::FromMicroseconds(20);
912 return kTestingConnectTimeMicros;
913 }
914
915 bool MockTCPClientSocket::WasNpnNegotiated() const { 903 bool MockTCPClientSocket::WasNpnNegotiated() const {
916 return false; 904 return false;
917 } 905 }
918 906
919 bool MockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { 907 bool MockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
920 return false; 908 return false;
921 } 909 }
922 910
923 void MockTCPClientSocket::OnReadComplete(const MockRead& data) { 911 void MockTCPClientSocket::OnReadComplete(const MockRead& data) {
924 // There must be a read pending. 912 // There must be a read pending.
(...skipping 30 matching lines...) Expand all
955 pending_callback_.Reset(); 943 pending_callback_.Reset();
956 944
957 int result = read_data_.result; 945 int result = read_data_.result;
958 DCHECK(result != ERR_IO_PENDING); 946 DCHECK(result != ERR_IO_PENDING);
959 947
960 if (read_data_.data) { 948 if (read_data_.data) {
961 if (read_data_.data_len - read_offset_ > 0) { 949 if (read_data_.data_len - read_offset_ > 0) {
962 result = std::min(buf_len, read_data_.data_len - read_offset_); 950 result = std::min(buf_len, read_data_.data_len - read_offset_);
963 memcpy(buf->data(), read_data_.data + read_offset_, result); 951 memcpy(buf->data(), read_data_.data + read_offset_, result);
964 read_offset_ += result; 952 read_offset_ += result;
965 num_bytes_read_ += result;
966 if (read_offset_ == read_data_.data_len) { 953 if (read_offset_ == read_data_.data_len) {
967 need_read_data_ = true; 954 need_read_data_ = true;
968 read_offset_ = 0; 955 read_offset_ = 0;
969 } 956 }
970 } else { 957 } else {
971 result = 0; // EOF 958 result = 0; // EOF
972 } 959 }
973 } 960 }
974 961
975 if (read_data_.mode == ASYNC) { 962 if (read_data_.mode == ASYNC) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 } 1091 }
1105 1092
1106 bool DeterministicMockTCPClientSocket::WasEverUsed() const { 1093 bool DeterministicMockTCPClientSocket::WasEverUsed() const {
1107 return was_used_to_convey_data_; 1094 return was_used_to_convey_data_;
1108 } 1095 }
1109 1096
1110 bool DeterministicMockTCPClientSocket::UsingTCPFastOpen() const { 1097 bool DeterministicMockTCPClientSocket::UsingTCPFastOpen() const {
1111 return false; 1098 return false;
1112 } 1099 }
1113 1100
1114 int64 DeterministicMockTCPClientSocket::NumBytesRead() const {
1115 return -1;
1116 }
1117
1118 base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const {
1119 return base::TimeDelta::FromMicroseconds(-1);
1120 }
1121
1122 bool DeterministicMockTCPClientSocket::WasNpnNegotiated() const { 1101 bool DeterministicMockTCPClientSocket::WasNpnNegotiated() const {
1123 return false; 1102 return false;
1124 } 1103 }
1125 1104
1126 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { 1105 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
1127 return false; 1106 return false;
1128 } 1107 }
1129 1108
1130 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} 1109 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {}
1131 1110
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 } 1177 }
1199 1178
1200 bool MockSSLClientSocket::WasEverUsed() const { 1179 bool MockSSLClientSocket::WasEverUsed() const {
1201 return transport_->socket()->WasEverUsed(); 1180 return transport_->socket()->WasEverUsed();
1202 } 1181 }
1203 1182
1204 bool MockSSLClientSocket::UsingTCPFastOpen() const { 1183 bool MockSSLClientSocket::UsingTCPFastOpen() const {
1205 return transport_->socket()->UsingTCPFastOpen(); 1184 return transport_->socket()->UsingTCPFastOpen();
1206 } 1185 }
1207 1186
1208 int64 MockSSLClientSocket::NumBytesRead() const {
1209 return -1;
1210 }
1211
1212 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { 1187 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const {
1213 return transport_->socket()->GetPeerAddress(address); 1188 return transport_->socket()->GetPeerAddress(address);
1214 } 1189 }
1215 1190
1216 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const {
1217 return base::TimeDelta::FromMicroseconds(-1);
1218 }
1219
1220 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { 1191 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
1221 ssl_info->Reset(); 1192 ssl_info->Reset();
1222 ssl_info->cert = data_->cert; 1193 ssl_info->cert = data_->cert;
1223 ssl_info->client_cert_sent = data_->client_cert_sent; 1194 ssl_info->client_cert_sent = data_->client_cert_sent;
1224 ssl_info->channel_id_sent = data_->channel_id_sent; 1195 ssl_info->channel_id_sent = data_->channel_id_sent;
1225 return true; 1196 return true;
1226 } 1197 }
1227 1198
1228 void MockSSLClientSocket::GetSSLCertRequestInfo( 1199 void MockSSLClientSocket::GetSSLCertRequestInfo(
1229 SSLCertRequestInfo* cert_request_info) { 1200 SSLCertRequestInfo* cert_request_info) {
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 1685
1715 const char kSOCKS5OkRequest[] = 1686 const char kSOCKS5OkRequest[] =
1716 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 1687 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1717 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 1688 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1718 1689
1719 const char kSOCKS5OkResponse[] = 1690 const char kSOCKS5OkResponse[] =
1720 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 1691 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1721 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 1692 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1722 1693
1723 } // namespace net 1694 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698