OLD | NEW |
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" | |
25 #include "net/socket/socket.h" | 24 #include "net/socket/socket.h" |
26 #include "net/socket/websocket_endpoint_lock_manager.h" | 25 #include "net/socket/websocket_endpoint_lock_manager.h" |
27 #include "net/ssl/ssl_cert_request_info.h" | 26 #include "net/ssl/ssl_cert_request_info.h" |
28 #include "net/ssl/ssl_connection_status_flags.h" | 27 #include "net/ssl/ssl_connection_status_flags.h" |
29 #include "net/ssl/ssl_info.h" | 28 #include "net/ssl/ssl_info.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
31 | 30 |
32 // 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. |
33 // 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. |
34 #if 0 | 33 #if 0 |
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 if (!user_callback_.is_null()) { | 1748 if (!user_callback_.is_null()) { |
1750 CompletionCallback callback = user_callback_; | 1749 CompletionCallback callback = user_callback_; |
1751 user_callback_.Reset(); | 1750 user_callback_.Reset(); |
1752 callback.Run(rv); | 1751 callback.Run(rv); |
1753 } | 1752 } |
1754 } | 1753 } |
1755 | 1754 |
1756 MockTransportClientSocketPool::MockTransportClientSocketPool( | 1755 MockTransportClientSocketPool::MockTransportClientSocketPool( |
1757 int max_sockets, | 1756 int max_sockets, |
1758 int max_sockets_per_group, | 1757 int max_sockets_per_group, |
1759 ClientSocketPoolHistograms* histograms, | |
1760 ClientSocketFactory* socket_factory) | 1758 ClientSocketFactory* socket_factory) |
1761 : TransportClientSocketPool(max_sockets, max_sockets_per_group, histograms, | 1759 : TransportClientSocketPool(max_sockets, |
1762 NULL, NULL, NULL), | 1760 max_sockets_per_group, |
| 1761 NULL, |
| 1762 NULL, |
| 1763 NULL), |
1763 client_socket_factory_(socket_factory), | 1764 client_socket_factory_(socket_factory), |
1764 last_request_priority_(DEFAULT_PRIORITY), | 1765 last_request_priority_(DEFAULT_PRIORITY), |
1765 release_count_(0), | 1766 release_count_(0), |
1766 cancel_count_(0) { | 1767 cancel_count_(0) { |
1767 } | 1768 } |
1768 | 1769 |
1769 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} | 1770 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} |
1770 | 1771 |
1771 int MockTransportClientSocketPool::RequestSocket( | 1772 int MockTransportClientSocketPool::RequestSocket( |
1772 const std::string& group_name, const void* socket_params, | 1773 const std::string& group_name, const void* socket_params, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 ssl_client_sockets_.push_back(socket.get()); | 1869 ssl_client_sockets_.push_back(socket.get()); |
1869 return socket.Pass(); | 1870 return socket.Pass(); |
1870 } | 1871 } |
1871 | 1872 |
1872 void DeterministicMockClientSocketFactory::ClearSSLSessionCache() { | 1873 void DeterministicMockClientSocketFactory::ClearSSLSessionCache() { |
1873 } | 1874 } |
1874 | 1875 |
1875 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( | 1876 MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( |
1876 int max_sockets, | 1877 int max_sockets, |
1877 int max_sockets_per_group, | 1878 int max_sockets_per_group, |
1878 ClientSocketPoolHistograms* histograms, | |
1879 TransportClientSocketPool* transport_pool) | 1879 TransportClientSocketPool* transport_pool) |
1880 : SOCKSClientSocketPool(max_sockets, max_sockets_per_group, histograms, | 1880 : SOCKSClientSocketPool(max_sockets, |
1881 NULL, transport_pool, NULL), | 1881 max_sockets_per_group, |
| 1882 NULL, |
| 1883 transport_pool, |
| 1884 NULL), |
1882 transport_pool_(transport_pool) { | 1885 transport_pool_(transport_pool) { |
1883 } | 1886 } |
1884 | 1887 |
1885 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} | 1888 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} |
1886 | 1889 |
1887 int MockSOCKSClientSocketPool::RequestSocket( | 1890 int MockSOCKSClientSocketPool::RequestSocket( |
1888 const std::string& group_name, const void* socket_params, | 1891 const std::string& group_name, const void* socket_params, |
1889 RequestPriority priority, ClientSocketHandle* handle, | 1892 RequestPriority priority, ClientSocketHandle* handle, |
1890 const CompletionCallback& callback, const BoundNetLog& net_log) { | 1893 const CompletionCallback& callback, const BoundNetLog& net_log) { |
1891 return transport_pool_->RequestSocket( | 1894 return transport_pool_->RequestSocket( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 | 1930 |
1928 const char kSOCKS5OkRequest[] = | 1931 const char kSOCKS5OkRequest[] = |
1929 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1932 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1930 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1933 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1931 | 1934 |
1932 const char kSOCKS5OkResponse[] = | 1935 const char kSOCKS5OkResponse[] = |
1933 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1936 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1934 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1937 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1935 | 1938 |
1936 } // namespace net | 1939 } // namespace net |
OLD | NEW |