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

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

Issue 835623003: Add a delay when unlocking WebSocket endpoints. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document WebSocketEndpointLockManager Created 5 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
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/websocket_endpoint_lock_manager.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"
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 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 ClientSocketHandle* handle) { 1977 ClientSocketHandle* handle) {
1977 return transport_pool_->CancelRequest(group_name, handle); 1978 return transport_pool_->CancelRequest(group_name, handle);
1978 } 1979 }
1979 1980
1980 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, 1981 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name,
1981 scoped_ptr<StreamSocket> socket, 1982 scoped_ptr<StreamSocket> socket,
1982 int id) { 1983 int id) {
1983 return transport_pool_->ReleaseSocket(group_name, socket.Pass(), id); 1984 return transport_pool_->ReleaseSocket(group_name, socket.Pass(), id);
1984 } 1985 }
1985 1986
1987 ScopedWebSocketEndpointZeroUnlockDelay::
1988 ScopedWebSocketEndpointZeroUnlockDelay() {
1989 old_delay_ =
1990 WebSocketEndpointLockManager::GetInstance()->SetUnlockDelayForTesting(
1991 base::TimeDelta());
1992 }
1993
1994 ScopedWebSocketEndpointZeroUnlockDelay::
1995 ~ScopedWebSocketEndpointZeroUnlockDelay() {
1996 base::TimeDelta active_delay =
1997 WebSocketEndpointLockManager::GetInstance()->SetUnlockDelayForTesting(
1998 old_delay_);
1999 EXPECT_EQ(active_delay, base::TimeDelta());
2000 }
2001
1986 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 2002 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
1987 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); 2003 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest);
1988 2004
1989 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 2005 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
1990 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); 2006 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse);
1991 2007
1992 const char kSOCKS5OkRequest[] = 2008 const char kSOCKS5OkRequest[] =
1993 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 2009 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1994 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 2010 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1995 2011
1996 const char kSOCKS5OkResponse[] = 2012 const char kSOCKS5OkResponse[] =
1997 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 2013 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1998 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 2014 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1999 2015
2000 } // namespace net 2016 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/websocket_endpoint_lock_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698