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

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

Issue 10690122: Change SpdySession::GetSSLInfo to get the SSLInfo from the underlying socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: FIx curvercp Created 8 years, 5 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip); 697 bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip);
698 CHECK(rv); 698 CHECK(rv);
699 *address = IPEndPoint(ip, 123); 699 *address = IPEndPoint(ip, 123);
700 return OK; 700 return OK;
701 } 701 }
702 702
703 const BoundNetLog& MockClientSocket::NetLog() const { 703 const BoundNetLog& MockClientSocket::NetLog() const {
704 return net_log_; 704 return net_log_;
705 } 705 }
706 706
707 void MockClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
708 NOTREACHED();
709 }
710
711 void MockClientSocket::GetSSLCertRequestInfo( 707 void MockClientSocket::GetSSLCertRequestInfo(
712 SSLCertRequestInfo* cert_request_info) { 708 SSLCertRequestInfo* cert_request_info) {
713 } 709 }
714 710
715 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label, 711 int MockClientSocket::ExportKeyingMaterial(const base::StringPiece& label,
716 bool has_context, 712 bool has_context,
717 const base::StringPiece& context, 713 const base::StringPiece& context,
718 unsigned char* out, 714 unsigned char* out,
719 unsigned int outlen) { 715 unsigned int outlen) {
720 memset(out, 'A', outlen); 716 memset(out, 'A', outlen);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 return num_bytes_read_; 861 return num_bytes_read_;
866 } 862 }
867 863
868 base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const { 864 base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const {
869 // Dummy value. 865 // Dummy value.
870 static const base::TimeDelta kTestingConnectTimeMicros = 866 static const base::TimeDelta kTestingConnectTimeMicros =
871 base::TimeDelta::FromMicroseconds(20); 867 base::TimeDelta::FromMicroseconds(20);
872 return kTestingConnectTimeMicros; 868 return kTestingConnectTimeMicros;
873 } 869 }
874 870
871 bool MockTCPClientSocket::WasNpnNegotiated() const {
872 return false;
873 }
874
875 bool MockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
876 return false;
877 }
878
875 void MockTCPClientSocket::OnReadComplete(const MockRead& data) { 879 void MockTCPClientSocket::OnReadComplete(const MockRead& data) {
876 // There must be a read pending. 880 // There must be a read pending.
877 DCHECK(pending_buf_); 881 DCHECK(pending_buf_);
878 // You can't complete a read with another ERR_IO_PENDING status code. 882 // You can't complete a read with another ERR_IO_PENDING status code.
879 DCHECK_NE(ERR_IO_PENDING, data.result); 883 DCHECK_NE(ERR_IO_PENDING, data.result);
880 // Since we've been waiting for data, need_read_data_ should be true. 884 // Since we've been waiting for data, need_read_data_ should be true.
881 DCHECK(need_read_data_); 885 DCHECK(need_read_data_);
882 886
883 read_data_ = data; 887 read_data_ = data;
884 need_read_data_ = false; 888 need_read_data_ = false;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1068 }
1065 1069
1066 int64 DeterministicMockTCPClientSocket::NumBytesRead() const { 1070 int64 DeterministicMockTCPClientSocket::NumBytesRead() const {
1067 return -1; 1071 return -1;
1068 } 1072 }
1069 1073
1070 base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const { 1074 base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const {
1071 return base::TimeDelta::FromMicroseconds(-1); 1075 return base::TimeDelta::FromMicroseconds(-1);
1072 } 1076 }
1073 1077
1078 bool DeterministicMockTCPClientSocket::WasNpnNegotiated() const {
1079 return false;
1080 }
1081
1082 bool DeterministicMockTCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
1083 return false;
1084 }
1085
1074 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} 1086 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {}
1075 1087
1076 // static 1088 // static
1077 void MockSSLClientSocket::ConnectCallback( 1089 void MockSSLClientSocket::ConnectCallback(
1078 MockSSLClientSocket *ssl_client_socket, 1090 MockSSLClientSocket *ssl_client_socket,
1079 const CompletionCallback& callback, 1091 const CompletionCallback& callback,
1080 int rv) { 1092 int rv) {
1081 if (rv == OK) 1093 if (rv == OK)
1082 ssl_client_socket->connected_ = true; 1094 ssl_client_socket->connected_ = true;
1083 callback.Run(rv); 1095 callback.Run(rv);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 } 1163 }
1152 1164
1153 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const { 1165 int MockSSLClientSocket::GetPeerAddress(IPEndPoint* address) const {
1154 return transport_->socket()->GetPeerAddress(address); 1166 return transport_->socket()->GetPeerAddress(address);
1155 } 1167 }
1156 1168
1157 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const { 1169 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const {
1158 return base::TimeDelta::FromMicroseconds(-1); 1170 return base::TimeDelta::FromMicroseconds(-1);
1159 } 1171 }
1160 1172
1161 void MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { 1173 bool MockSSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
1162 ssl_info->Reset(); 1174 ssl_info->Reset();
1163 ssl_info->cert = data_->cert; 1175 ssl_info->cert = data_->cert;
1164 ssl_info->client_cert_sent = data_->client_cert_sent; 1176 ssl_info->client_cert_sent = data_->client_cert_sent;
1165 ssl_info->channel_id_sent = data_->channel_id_sent; 1177 ssl_info->channel_id_sent = data_->channel_id_sent;
1178 return true;
1166 } 1179 }
1167 1180
1168 void MockSSLClientSocket::GetSSLCertRequestInfo( 1181 void MockSSLClientSocket::GetSSLCertRequestInfo(
1169 SSLCertRequestInfo* cert_request_info) { 1182 SSLCertRequestInfo* cert_request_info) {
1170 DCHECK(cert_request_info); 1183 DCHECK(cert_request_info);
1171 if (data_->cert_request_info) { 1184 if (data_->cert_request_info) {
1172 cert_request_info->host_and_port = 1185 cert_request_info->host_and_port =
1173 data_->cert_request_info->host_and_port; 1186 data_->cert_request_info->host_and_port;
1174 cert_request_info->client_certs = data_->cert_request_info->client_certs; 1187 cert_request_info->client_certs = data_->cert_request_info->client_certs;
1175 } else { 1188 } else {
1176 cert_request_info->Reset(); 1189 cert_request_info->Reset();
1177 } 1190 }
1178 } 1191 }
1179 1192
1180 SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto( 1193 SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto(
1181 std::string* proto, std::string* server_protos) { 1194 std::string* proto, std::string* server_protos) {
1182 *proto = data_->next_proto; 1195 *proto = data_->next_proto;
1183 *server_protos = data_->server_protos; 1196 *server_protos = data_->server_protos;
1184 return data_->next_proto_status; 1197 return data_->next_proto_status;
1185 } 1198 }
1186 1199
1187 bool MockSSLClientSocket::was_npn_negotiated() const {
1188 if (is_npn_state_set_)
1189 return new_npn_value_;
1190 return data_->was_npn_negotiated;
1191 }
1192
1193 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { 1200 bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) {
1194 is_npn_state_set_ = true; 1201 is_npn_state_set_ = true;
1195 return new_npn_value_ = negotiated; 1202 return new_npn_value_ = negotiated;
1196 } 1203 }
1197 1204
1205 bool MockSSLClientSocket::WasNpnNegotiated() const {
1206 if (is_npn_state_set_)
1207 return new_npn_value_;
1208 return data_->was_npn_negotiated;
1209 }
1210
1198 NextProto MockSSLClientSocket::GetNegotiatedProtocol() const { 1211 NextProto MockSSLClientSocket::GetNegotiatedProtocol() const {
1199 if (is_protocol_negotiated_set_) 1212 if (is_protocol_negotiated_set_)
1200 return protocol_negotiated_; 1213 return protocol_negotiated_;
1201 return data_->protocol_negotiated; 1214 return data_->protocol_negotiated;
1202 } 1215 }
1203 1216
1204 void MockSSLClientSocket::set_protocol_negotiated( 1217 void MockSSLClientSocket::set_protocol_negotiated(
1205 NextProto protocol_negotiated) { 1218 NextProto protocol_negotiated) {
1206 is_protocol_negotiated_set_ = true; 1219 is_protocol_negotiated_set_ = true;
1207 protocol_negotiated_ = protocol_negotiated; 1220 protocol_negotiated_ = protocol_negotiated;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1656
1644 const char kSOCKS5OkRequest[] = 1657 const char kSOCKS5OkRequest[] =
1645 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 1658 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1646 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 1659 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1647 1660
1648 const char kSOCKS5OkResponse[] = 1661 const char kSOCKS5OkResponse[] =
1649 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 1662 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1650 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 1663 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1651 1664
1652 } // namespace net 1665 } // 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