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

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

Issue 135373002: Added SSLHostInfo. Storing of server host info to our standard disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 years, 11 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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "net/base/address_family.h" 17 #include "net/base/address_family.h"
18 #include "net/base/address_list.h" 18 #include "net/base/address_list.h"
19 #include "net/base/auth.h" 19 #include "net/base/auth.h"
20 #include "net/base/load_timing_info.h" 20 #include "net/base/load_timing_info.h"
21 #include "net/http/http_network_session.h" 21 #include "net/http/http_network_session.h"
22 #include "net/http/http_request_headers.h" 22 #include "net/http/http_request_headers.h"
23 #include "net/http/http_response_headers.h" 23 #include "net/http/http_response_headers.h"
24 #include "net/socket/client_socket_pool_histograms.h" 24 #include "net/socket/client_socket_pool_histograms.h"
25 #include "net/socket/socket.h" 25 #include "net/socket/socket.h"
26 #include "net/socket/ssl_host_info.h"
26 #include "net/ssl/ssl_cert_request_info.h" 27 #include "net/ssl/ssl_cert_request_info.h"
27 #include "net/ssl/ssl_info.h" 28 #include "net/ssl/ssl_info.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 // Socket events are easier to debug if you log individual reads and writes. 31 // Socket events are easier to debug if you log individual reads and writes.
31 // Enable these if locally debugging, but they are too noisy for the waterfall. 32 // Enable these if locally debugging, but they are too noisy for the waterfall.
32 #if 0 33 #if 0
33 #define NET_TRACE(level, s) DLOG(level) << s << __FUNCTION__ << "() " 34 #define NET_TRACE(level, s) DLOG(level) << s << __FUNCTION__ << "() "
34 #else 35 #else
35 #define NET_TRACE(level, s) EAT_STREAM_PARAMETERS 36 #define NET_TRACE(level, s) EAT_STREAM_PARAMETERS
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 scoped_ptr<MockTCPClientSocket> socket( 681 scoped_ptr<MockTCPClientSocket> socket(
681 new MockTCPClientSocket(addresses, net_log, data_provider)); 682 new MockTCPClientSocket(addresses, net_log, data_provider));
682 data_provider->set_socket(socket.get()); 683 data_provider->set_socket(socket.get());
683 return socket.PassAs<StreamSocket>(); 684 return socket.PassAs<StreamSocket>();
684 } 685 }
685 686
686 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket( 687 scoped_ptr<SSLClientSocket> MockClientSocketFactory::CreateSSLClientSocket(
687 scoped_ptr<ClientSocketHandle> transport_socket, 688 scoped_ptr<ClientSocketHandle> transport_socket,
688 const HostPortPair& host_and_port, 689 const HostPortPair& host_and_port,
689 const SSLConfig& ssl_config, 690 const SSLConfig& ssl_config,
691 SSLHostInfo* ssl_host_info,
690 const SSLClientSocketContext& context) { 692 const SSLClientSocketContext& context) {
691 return scoped_ptr<SSLClientSocket>( 693 return scoped_ptr<SSLClientSocket>(
692 new MockSSLClientSocket(transport_socket.Pass(), 694 new MockSSLClientSocket(transport_socket.Pass(),
693 host_and_port, ssl_config, 695 host_and_port, ssl_config,
694 mock_ssl_data_.GetNext())); 696 ssl_host_info, mock_ssl_data_.GetNext()));
695 } 697 }
696 698
697 void MockClientSocketFactory::ClearSSLSessionCache() { 699 void MockClientSocketFactory::ClearSSLSessionCache() {
698 } 700 }
699 701
700 const char MockClientSocket::kTlsUnique[] = "MOCK_TLSUNIQ"; 702 const char MockClientSocket::kTlsUnique[] = "MOCK_TLSUNIQ";
701 703
702 MockClientSocket::MockClientSocket(const BoundNetLog& net_log) 704 MockClientSocket::MockClientSocket(const BoundNetLog& net_log)
703 : connected_(false), 705 : connected_(false),
704 net_log_(net_log), 706 net_log_(net_log),
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 int rv) { 1290 int rv) {
1289 if (rv == OK) 1291 if (rv == OK)
1290 ssl_client_socket->connected_ = true; 1292 ssl_client_socket->connected_ = true;
1291 callback.Run(rv); 1293 callback.Run(rv);
1292 } 1294 }
1293 1295
1294 MockSSLClientSocket::MockSSLClientSocket( 1296 MockSSLClientSocket::MockSSLClientSocket(
1295 scoped_ptr<ClientSocketHandle> transport_socket, 1297 scoped_ptr<ClientSocketHandle> transport_socket,
1296 const HostPortPair& host_port_pair, 1298 const HostPortPair& host_port_pair,
1297 const SSLConfig& ssl_config, 1299 const SSLConfig& ssl_config,
1300 SSLHostInfo* ssl_host_info,
1298 SSLSocketDataProvider* data) 1301 SSLSocketDataProvider* data)
1299 : MockClientSocket( 1302 : MockClientSocket(
1300 // Have to use the right BoundNetLog for LoadTimingInfo regression 1303 // Have to use the right BoundNetLog for LoadTimingInfo regression
1301 // tests. 1304 // tests.
1302 transport_socket->socket()->NetLog()), 1305 transport_socket->socket()->NetLog()),
1303 transport_(transport_socket.Pass()), 1306 transport_(transport_socket.Pass()),
1304 data_(data), 1307 data_(data),
1305 is_npn_state_set_(false), 1308 is_npn_state_set_(false),
1306 new_npn_value_(false), 1309 new_npn_value_(false),
1307 is_protocol_negotiated_set_(false), 1310 is_protocol_negotiated_set_(false),
1308 protocol_negotiated_(kProtoUnknown) { 1311 protocol_negotiated_(kProtoUnknown) {
1309 DCHECK(data_); 1312 DCHECK(data_);
1310 peer_addr_ = data->connect.peer_addr; 1313 peer_addr_ = data->connect.peer_addr;
1314 delete ssl_host_info; // we take ownership but don't use it.
1311 } 1315 }
1312 1316
1313 MockSSLClientSocket::~MockSSLClientSocket() { 1317 MockSSLClientSocket::~MockSSLClientSocket() {
1314 Disconnect(); 1318 Disconnect();
1315 } 1319 }
1316 1320
1317 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len, 1321 int MockSSLClientSocket::Read(IOBuffer* buf, int buf_len,
1318 const CompletionCallback& callback) { 1322 const CompletionCallback& callback) {
1319 return transport_->socket()->Read(buf, buf_len, callback); 1323 return transport_->socket()->Read(buf, buf_len, callback);
1320 } 1324 }
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 data_provider->set_delegate(socket->AsWeakPtr()); 1833 data_provider->set_delegate(socket->AsWeakPtr());
1830 tcp_client_sockets().push_back(socket.get()); 1834 tcp_client_sockets().push_back(socket.get());
1831 return socket.PassAs<StreamSocket>(); 1835 return socket.PassAs<StreamSocket>();
1832 } 1836 }
1833 1837
1834 scoped_ptr<SSLClientSocket> 1838 scoped_ptr<SSLClientSocket>
1835 DeterministicMockClientSocketFactory::CreateSSLClientSocket( 1839 DeterministicMockClientSocketFactory::CreateSSLClientSocket(
1836 scoped_ptr<ClientSocketHandle> transport_socket, 1840 scoped_ptr<ClientSocketHandle> transport_socket,
1837 const HostPortPair& host_and_port, 1841 const HostPortPair& host_and_port,
1838 const SSLConfig& ssl_config, 1842 const SSLConfig& ssl_config,
1843 SSLHostInfo* ssl_host_info,
1839 const SSLClientSocketContext& context) { 1844 const SSLClientSocketContext& context) {
1840 scoped_ptr<MockSSLClientSocket> socket( 1845 scoped_ptr<MockSSLClientSocket> socket(
1841 new MockSSLClientSocket(transport_socket.Pass(), 1846 new MockSSLClientSocket(transport_socket.Pass(),
1842 host_and_port, ssl_config, 1847 host_and_port, ssl_config,
1843 mock_ssl_data_.GetNext())); 1848 ssl_host_info, mock_ssl_data_.GetNext()));
1844 ssl_client_sockets_.push_back(socket.get()); 1849 ssl_client_sockets_.push_back(socket.get());
1845 return socket.PassAs<SSLClientSocket>(); 1850 return socket.PassAs<SSLClientSocket>();
1846 } 1851 }
1847 1852
1848 void DeterministicMockClientSocketFactory::ClearSSLSessionCache() { 1853 void DeterministicMockClientSocketFactory::ClearSSLSessionCache() {
1849 } 1854 }
1850 1855
1851 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( 1856 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool(
1852 int max_sockets, 1857 int max_sockets,
1853 int max_sockets_per_group, 1858 int max_sockets_per_group,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 1893
1889 const char kSOCKS5OkRequest[] = 1894 const char kSOCKS5OkRequest[] =
1890 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 1895 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1891 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 1896 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1892 1897
1893 const char kSOCKS5OkResponse[] = 1898 const char kSOCKS5OkResponse[] =
1894 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 1899 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1895 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 1900 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1896 1901
1897 } // namespace net 1902 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698