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

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

Issue 14232014: Correctly handle SPDY GOAWAY frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments Created 7 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_spdy2_unittest.cc ('k') | net/spdy/spdy_test_util_spdy2.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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/ip_endpoint.h" 9 #include "net/base/ip_endpoint.h"
10 #include "net/base/net_log_unittest.h" 10 #include "net/base/net_log_unittest.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 SpdySessionPool* spdy_session_pool_; 120 SpdySessionPool* spdy_session_pool_;
121 GURL test_url_; 121 GURL test_url_;
122 HostPortPair test_host_port_pair_; 122 HostPortPair test_host_port_pair_;
123 HostPortProxyPair pair_; 123 HostPortProxyPair pair_;
124 }; 124 };
125 125
126 TEST_F(SpdySessionSpdy3Test, GoAway) { 126 TEST_F(SpdySessionSpdy3Test, GoAway) {
127 session_deps_.host_resolver->set_synchronous_mode(true); 127 session_deps_.host_resolver->set_synchronous_mode(true);
128 128
129 MockConnect connect_data(SYNCHRONOUS, OK); 129 MockConnect connect_data(SYNCHRONOUS, OK);
130 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); 130 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway(1));
131 MockRead reads[] = { 131 MockRead reads[] = {
132 CreateMockRead(*goaway), 132 CreateMockRead(*goaway, 2),
133 MockRead(SYNCHRONOUS, 0, 0) // EOF 133 MockRead(ASYNC, 0, 3) // EOF
134 }; 134 };
135 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 135 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM));
136 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, MEDIUM));
137 MockWrite writes[] = {
138 CreateMockWrite(*req1, 0),
139 CreateMockWrite(*req2, 1),
140 };
141 DeterministicSocketData data(reads, arraysize(reads),
142 writes, arraysize(writes));
136 data.set_connect_data(connect_data); 143 data.set_connect_data(connect_data);
137 session_deps_.socket_factory->AddSocketDataProvider(&data); 144 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data);
138 145
139 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 146 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
140 ssl.SetNextProto(kProtoSPDY3); 147 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
141 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
142 148
143 CreateNetworkSession(); 149 CreateDeterministicNetworkSession();
144 150
145 scoped_refptr<SpdySession> session = CreateInitializedSession(); 151 scoped_refptr<SpdySession> session = CreateInitializedSession();
146 152
147 EXPECT_EQ(3, session->GetProtocolVersion()); 153 EXPECT_EQ(3, session->GetProtocolVersion());
148 154
149 // Flush the SpdySession::OnReadComplete() task. 155 GURL url("http://www.google.com");
150 MessageLoop::current()->RunUntilIdle(); 156 scoped_refptr<SpdyStream> spdy_stream1 =
157 CreateStreamSynchronously(session, url, MEDIUM, BoundNetLog());
158
159 scoped_refptr<SpdyStream> spdy_stream2 =
160 CreateStreamSynchronously(session, url, MEDIUM, BoundNetLog());
161
162 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
163 (*headers)[":method"] = "GET";
164 (*headers)[":scheme"] = url.scheme();
165 (*headers)[":host"] = url.host();
166 (*headers)[":path"] = url.path();
167 (*headers)[":version"] = "HTTP/1.1";
168 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock);
169 *headers2 = *headers;
170
171 spdy_stream1->set_spdy_headers(headers.Pass());
172 EXPECT_TRUE(spdy_stream1->HasUrl());
173
174 spdy_stream2->set_spdy_headers(headers2.Pass());
175 EXPECT_TRUE(spdy_stream2->HasUrl());
176
177 spdy_stream1->SendRequest(false);
178 spdy_stream2->SendRequest(false);
179 data.RunFor(2);
180
181 EXPECT_EQ(1u, spdy_stream1->stream_id());
182 EXPECT_EQ(3u, spdy_stream2->stream_id());
183
184 EXPECT_TRUE(spdy_session_pool_->HasSession(pair_));
185
186 // Read and process the GOAWAY frame.
187 data.RunFor(1);
151 188
152 EXPECT_FALSE(spdy_session_pool_->HasSession(pair_)); 189 EXPECT_FALSE(spdy_session_pool_->HasSession(pair_));
153 190
191 EXPECT_TRUE(session->IsStreamActive(1));
192 EXPECT_FALSE(session->IsStreamActive(3));
193
154 scoped_refptr<SpdySession> session2 = GetSession(pair_); 194 scoped_refptr<SpdySession> session2 = GetSession(pair_);
155 195
196 spdy_stream1->Close();
197 spdy_stream1 = NULL;
198 spdy_stream2 = NULL;
199
156 // Delete the first session. 200 // Delete the first session.
157 session = NULL; 201 session = NULL;
158 202
159 // Delete the second session. 203 // Delete the second session.
160 spdy_session_pool_->Remove(session2); 204 spdy_session_pool_->Remove(session2);
161 session2 = NULL; 205 session2 = NULL;
162 } 206 }
163 207
164 TEST_F(SpdySessionSpdy3Test, ClientPing) { 208 TEST_F(SpdySessionSpdy3Test, ClientPing) {
165 session_deps_.enable_ping = true; 209 session_deps_.enable_ping = true;
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 EXPECT_EQ(0u, spdy_stream2->stream_id()); 1187 EXPECT_EQ(0u, spdy_stream2->stream_id());
1144 1188
1145 // Ensure we don't crash while closing the session. 1189 // Ensure we don't crash while closing the session.
1146 session->CloseSessionOnError(ERR_ABORTED, true, std::string()); 1190 session->CloseSessionOnError(ERR_ABORTED, true, std::string());
1147 1191
1148 EXPECT_TRUE(spdy_stream1->closed()); 1192 EXPECT_TRUE(spdy_stream1->closed());
1149 EXPECT_TRUE(spdy_stream2->closed()); 1193 EXPECT_TRUE(spdy_stream2->closed());
1150 1194
1151 spdy_stream1 = NULL; 1195 spdy_stream1 = NULL;
1152 spdy_stream2 = NULL; 1196 spdy_stream2 = NULL;
1197 session = NULL;
1153 } 1198 }
1154 1199
1155 TEST_F(SpdySessionSpdy3Test, VerifyDomainAuthentication) { 1200 TEST_F(SpdySessionSpdy3Test, VerifyDomainAuthentication) {
1156 session_deps_.host_resolver->set_synchronous_mode(true); 1201 session_deps_.host_resolver->set_synchronous_mode(true);
1157 1202
1158 MockConnect connect_data(SYNCHRONOUS, OK); 1203 MockConnect connect_data(SYNCHRONOUS, OK);
1159 1204
1160 // No actual data will be sent. 1205 // No actual data will be sent.
1161 MockWrite writes[] = { 1206 MockWrite writes[] = {
1162 MockWrite(ASYNC, 0, 1) // EOF 1207 MockWrite(ASYNC, 0, 1) // EOF
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 EXPECT_EQ(0, delegate1.body_data_sent()); 3018 EXPECT_EQ(0, delegate1.body_data_sent());
2974 3019
2975 EXPECT_TRUE(delegate2.send_headers_completed()); 3020 EXPECT_TRUE(delegate2.send_headers_completed());
2976 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); 3021 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status"));
2977 EXPECT_EQ("HTTP/1.1", delegate2.GetResponseHeaderValue(":version")); 3022 EXPECT_EQ("HTTP/1.1", delegate2.GetResponseHeaderValue(":version"));
2978 EXPECT_EQ("", delegate2.received_data()); 3023 EXPECT_EQ("", delegate2.received_data());
2979 EXPECT_EQ(0, delegate2.body_data_sent()); 3024 EXPECT_EQ(0, delegate2.body_data_sent());
2980 } 3025 }
2981 3026
2982 } // namespace net 3027 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_spdy2_unittest.cc ('k') | net/spdy/spdy_test_util_spdy2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698