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

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

Powered by Google App Engine
This is Rietveld 408576698