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/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "net/base/address_family.h" | 18 #include "net/base/address_family.h" |
19 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
20 #include "net/base/auth.h" | 20 #include "net/base/auth.h" |
21 #include "net/base/load_timing_info.h" | 21 #include "net/base/load_timing_info.h" |
22 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
23 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
24 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
25 #include "net/socket/client_socket_pool_histograms.h" | 25 #include "net/socket/client_socket_pool_histograms.h" |
26 #include "net/socket/socket.h" | 26 #include "net/socket/socket.h" |
| 27 #include "net/socket/websocket_endpoint_lock_manager.h" |
27 #include "net/ssl/ssl_cert_request_info.h" | 28 #include "net/ssl/ssl_cert_request_info.h" |
28 #include "net/ssl/ssl_connection_status_flags.h" | 29 #include "net/ssl/ssl_connection_status_flags.h" |
29 #include "net/ssl/ssl_info.h" | 30 #include "net/ssl/ssl_info.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
31 | 32 |
32 // Socket events are easier to debug if you log individual reads and writes. | 33 // 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. | 34 // Enable these if locally debugging, but they are too noisy for the waterfall. |
34 #if 0 | 35 #if 0 |
35 #define NET_TRACE(level, s) DLOG(level) << s << __FUNCTION__ << "() " | 36 #define NET_TRACE(level, s) DLOG(level) << s << __FUNCTION__ << "() " |
36 #else | 37 #else |
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 ClientSocketHandle* handle) { | 1983 ClientSocketHandle* handle) { |
1983 return transport_pool_->CancelRequest(group_name, handle); | 1984 return transport_pool_->CancelRequest(group_name, handle); |
1984 } | 1985 } |
1985 | 1986 |
1986 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, | 1987 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, |
1987 scoped_ptr<StreamSocket> socket, | 1988 scoped_ptr<StreamSocket> socket, |
1988 int id) { | 1989 int id) { |
1989 return transport_pool_->ReleaseSocket(group_name, socket.Pass(), id); | 1990 return transport_pool_->ReleaseSocket(group_name, socket.Pass(), id); |
1990 } | 1991 } |
1991 | 1992 |
| 1993 ScopedWebSocketEndpointZeroUnlockDelay:: |
| 1994 ScopedWebSocketEndpointZeroUnlockDelay() { |
| 1995 old_delay_ = |
| 1996 WebSocketEndpointLockManager::GetInstance()->SetUnlockDelayForTesting( |
| 1997 base::TimeDelta()); |
| 1998 } |
| 1999 |
| 2000 ScopedWebSocketEndpointZeroUnlockDelay:: |
| 2001 ~ScopedWebSocketEndpointZeroUnlockDelay() { |
| 2002 base::TimeDelta active_delay = |
| 2003 WebSocketEndpointLockManager::GetInstance()->SetUnlockDelayForTesting( |
| 2004 old_delay_); |
| 2005 EXPECT_EQ(active_delay, base::TimeDelta()); |
| 2006 } |
| 2007 |
1992 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; | 2008 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; |
1993 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); | 2009 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); |
1994 | 2010 |
1995 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; | 2011 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; |
1996 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); | 2012 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); |
1997 | 2013 |
1998 const char kSOCKS5OkRequest[] = | 2014 const char kSOCKS5OkRequest[] = |
1999 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2015 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
2000 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2016 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
2001 | 2017 |
2002 const char kSOCKS5OkResponse[] = | 2018 const char kSOCKS5OkResponse[] = |
2003 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2019 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
2004 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2020 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
2005 | 2021 |
2006 } // namespace net | 2022 } // namespace net |
OLD | NEW |