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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 215023002: Rename PrivateMode enum values: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 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/spdy/spdy_session_pool_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( 100 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group(
101 HttpNetworkSession::NORMAL_SOCKET_POOL)), 101 HttpNetworkSession::NORMAL_SOCKET_POOL)),
102 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( 102 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool(
103 HttpNetworkSession::NORMAL_SOCKET_POOL)), 103 HttpNetworkSession::NORMAL_SOCKET_POOL)),
104 spdy_util_(GetParam()), 104 spdy_util_(GetParam()),
105 session_deps_(GetParam()), 105 session_deps_(GetParam()),
106 spdy_session_pool_(NULL), 106 spdy_session_pool_(NULL),
107 test_url_(kTestUrl), 107 test_url_(kTestUrl),
108 test_host_port_pair_(kTestHost, kTestPort), 108 test_host_port_pair_(kTestHost, kTestPort),
109 key_(test_host_port_pair_, ProxyServer::Direct(), 109 key_(test_host_port_pair_, ProxyServer::Direct(),
110 kPrivacyModeDisabled) { 110 PRIVACY_MODE_DISABLED) {
111 } 111 }
112 112
113 virtual ~SpdySessionTest() { 113 virtual ~SpdySessionTest() {
114 // Important to restore the per-pool limit first, since the pool limit must 114 // Important to restore the per-pool limit first, since the pool limit must
115 // always be greater than group limit, and the tests reduce both limits. 115 // always be greater than group limit, and the tests reduce both limits.
116 ClientSocketPoolManager::set_max_sockets_per_pool( 116 ClientSocketPoolManager::set_max_sockets_per_pool(
117 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); 117 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_);
118 ClientSocketPoolManager::set_max_sockets_per_group( 118 ClientSocketPoolManager::set_max_sockets_per_group(
119 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_group_sockets_); 119 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_group_sockets_);
120 } 120 }
(...skipping 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 session_deps_.socket_factory->AddSocketDataProvider(&data); 2712 session_deps_.socket_factory->AddSocketDataProvider(&data);
2713 2713
2714 CreateNetworkSession(); 2714 CreateNetworkSession();
2715 2715
2716 TransportClientSocketPool* pool = 2716 TransportClientSocketPool* pool =
2717 http_session_->GetTransportSocketPool( 2717 http_session_->GetTransportSocketPool(
2718 HttpNetworkSession::NORMAL_SOCKET_POOL); 2718 HttpNetworkSession::NORMAL_SOCKET_POOL);
2719 2719
2720 // Create an idle SPDY session. 2720 // Create an idle SPDY session.
2721 SpdySessionKey key1(HostPortPair("1.com", 80), ProxyServer::Direct(), 2721 SpdySessionKey key1(HostPortPair("1.com", 80), ProxyServer::Direct(),
2722 kPrivacyModeDisabled); 2722 PRIVACY_MODE_DISABLED);
2723 base::WeakPtr<SpdySession> session1 = 2723 base::WeakPtr<SpdySession> session1 =
2724 CreateInsecureSpdySession(http_session_, key1, BoundNetLog()); 2724 CreateInsecureSpdySession(http_session_, key1, BoundNetLog());
2725 EXPECT_FALSE(pool->IsStalled()); 2725 EXPECT_FALSE(pool->IsStalled());
2726 2726
2727 // Trying to create a new connection should cause the pool to be stalled, and 2727 // Trying to create a new connection should cause the pool to be stalled, and
2728 // post a task asynchronously to try and close the session. 2728 // post a task asynchronously to try and close the session.
2729 TestCompletionCallback callback2; 2729 TestCompletionCallback callback2;
2730 HostPortPair host_port2("2.com", 80); 2730 HostPortPair host_port2("2.com", 80);
2731 scoped_refptr<TransportSocketParams> params2( 2731 scoped_refptr<TransportSocketParams> params2(
2732 new TransportSocketParams(host_port2, false, false, 2732 new TransportSocketParams(host_port2, false, false,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 "3.com", "192.168.0.3", std::string()); 2772 "3.com", "192.168.0.3", std::string());
2773 2773
2774 CreateNetworkSession(); 2774 CreateNetworkSession();
2775 2775
2776 TransportClientSocketPool* pool = 2776 TransportClientSocketPool* pool =
2777 http_session_->GetTransportSocketPool( 2777 http_session_->GetTransportSocketPool(
2778 HttpNetworkSession::NORMAL_SOCKET_POOL); 2778 HttpNetworkSession::NORMAL_SOCKET_POOL);
2779 2779
2780 // Create an idle SPDY session. 2780 // Create an idle SPDY session.
2781 SpdySessionKey key1(HostPortPair("1.com", 80), ProxyServer::Direct(), 2781 SpdySessionKey key1(HostPortPair("1.com", 80), ProxyServer::Direct(),
2782 kPrivacyModeDisabled); 2782 PRIVACY_MODE_DISABLED);
2783 base::WeakPtr<SpdySession> session1 = 2783 base::WeakPtr<SpdySession> session1 =
2784 CreateInsecureSpdySession(http_session_, key1, BoundNetLog()); 2784 CreateInsecureSpdySession(http_session_, key1, BoundNetLog());
2785 EXPECT_FALSE(pool->IsStalled()); 2785 EXPECT_FALSE(pool->IsStalled());
2786 2786
2787 // Set up an alias for the idle SPDY session, increasing its ref count to 2. 2787 // Set up an alias for the idle SPDY session, increasing its ref count to 2.
2788 SpdySessionKey key2(HostPortPair("2.com", 80), ProxyServer::Direct(), 2788 SpdySessionKey key2(HostPortPair("2.com", 80), ProxyServer::Direct(),
2789 kPrivacyModeDisabled); 2789 PRIVACY_MODE_DISABLED);
2790 HostResolver::RequestInfo info(key2.host_port_pair()); 2790 HostResolver::RequestInfo info(key2.host_port_pair());
2791 AddressList addresses; 2791 AddressList addresses;
2792 // Pre-populate the DNS cache, since a synchronous resolution is required in 2792 // Pre-populate the DNS cache, since a synchronous resolution is required in
2793 // order to create the alias. 2793 // order to create the alias.
2794 session_deps_.host_resolver->Resolve(info, 2794 session_deps_.host_resolver->Resolve(info,
2795 DEFAULT_PRIORITY, 2795 DEFAULT_PRIORITY,
2796 &addresses, 2796 &addresses,
2797 CompletionCallback(), 2797 CompletionCallback(),
2798 NULL, 2798 NULL,
2799 BoundNetLog()); 2799 BoundNetLog());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2860 2860
2861 CreateNetworkSession(); 2861 CreateNetworkSession();
2862 2862
2863 TransportClientSocketPool* pool = 2863 TransportClientSocketPool* pool =
2864 http_session_->GetTransportSocketPool( 2864 http_session_->GetTransportSocketPool(
2865 HttpNetworkSession::NORMAL_SOCKET_POOL); 2865 HttpNetworkSession::NORMAL_SOCKET_POOL);
2866 2866
2867 // Create a SPDY session. 2867 // Create a SPDY session.
2868 GURL url1(kDefaultURL); 2868 GURL url1(kDefaultURL);
2869 SpdySessionKey key1(HostPortPair(url1.host(), 80), 2869 SpdySessionKey key1(HostPortPair(url1.host(), 80),
2870 ProxyServer::Direct(), kPrivacyModeDisabled); 2870 ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
2871 base::WeakPtr<SpdySession> session1 = 2871 base::WeakPtr<SpdySession> session1 =
2872 CreateInsecureSpdySession(http_session_, key1, BoundNetLog()); 2872 CreateInsecureSpdySession(http_session_, key1, BoundNetLog());
2873 EXPECT_FALSE(pool->IsStalled()); 2873 EXPECT_FALSE(pool->IsStalled());
2874 2874
2875 // Create a stream using the session, and send a request. 2875 // Create a stream using the session, and send a request.
2876 2876
2877 TestCompletionCallback callback1; 2877 TestCompletionCallback callback1;
2878 base::WeakPtr<SpdyStream> spdy_stream1 = 2878 base::WeakPtr<SpdyStream> spdy_stream1 =
2879 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM, 2879 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
2880 session1, url1, DEFAULT_PRIORITY, 2880 session1, url1, DEFAULT_PRIORITY,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 EXPECT_EQ(OK, callback2.WaitForResult()); 2921 EXPECT_EQ(OK, callback2.WaitForResult());
2922 } 2922 }
2923 2923
2924 // Verify that SpdySessionKey and therefore SpdySession is different when 2924 // Verify that SpdySessionKey and therefore SpdySession is different when
2925 // privacy mode is enabled or disabled. 2925 // privacy mode is enabled or disabled.
2926 TEST_P(SpdySessionTest, SpdySessionKeyPrivacyMode) { 2926 TEST_P(SpdySessionTest, SpdySessionKeyPrivacyMode) {
2927 CreateDeterministicNetworkSession(); 2927 CreateDeterministicNetworkSession();
2928 2928
2929 HostPortPair host_port_pair("www.google.com", 443); 2929 HostPortPair host_port_pair("www.google.com", 443);
2930 SpdySessionKey key_privacy_enabled(host_port_pair, ProxyServer::Direct(), 2930 SpdySessionKey key_privacy_enabled(host_port_pair, ProxyServer::Direct(),
2931 kPrivacyModeEnabled); 2931 PRIVACY_MODE_ENABLED);
2932 SpdySessionKey key_privacy_disabled(host_port_pair, ProxyServer::Direct(), 2932 SpdySessionKey key_privacy_disabled(host_port_pair, ProxyServer::Direct(),
2933 kPrivacyModeDisabled); 2933 PRIVACY_MODE_DISABLED);
2934 2934
2935 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_privacy_enabled)); 2935 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_privacy_enabled));
2936 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_privacy_disabled)); 2936 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_privacy_disabled));
2937 2937
2938 // Add SpdySession with PrivacyMode Enabled to the pool. 2938 // Add SpdySession with PrivacyMode Enabled to the pool.
2939 base::WeakPtr<SpdySession> session_privacy_enabled = 2939 base::WeakPtr<SpdySession> session_privacy_enabled =
2940 CreateFakeSpdySession(spdy_session_pool_, key_privacy_enabled); 2940 CreateFakeSpdySession(spdy_session_pool_, key_privacy_enabled);
2941 2941
2942 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_privacy_enabled)); 2942 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_privacy_enabled));
2943 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_privacy_disabled)); 2943 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_privacy_disabled));
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
4139 TEST(MapRstStreamStatusToProtocolError, MapsValues) { 4139 TEST(MapRstStreamStatusToProtocolError, MapsValues) {
4140 CHECK_EQ(STATUS_CODE_PROTOCOL_ERROR, 4140 CHECK_EQ(STATUS_CODE_PROTOCOL_ERROR,
4141 MapRstStreamStatusToProtocolError( 4141 MapRstStreamStatusToProtocolError(
4142 RST_STREAM_PROTOCOL_ERROR)); 4142 RST_STREAM_PROTOCOL_ERROR));
4143 CHECK_EQ(STATUS_CODE_FRAME_TOO_LARGE, 4143 CHECK_EQ(STATUS_CODE_FRAME_TOO_LARGE,
4144 MapRstStreamStatusToProtocolError( 4144 MapRstStreamStatusToProtocolError(
4145 RST_STREAM_FRAME_TOO_LARGE)); 4145 RST_STREAM_FRAME_TOO_LARGE));
4146 } 4146 }
4147 4147
4148 } // namespace net 4148 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_pool_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698