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

Side by Side Diff: net/http/http_network_transaction_spdy3_unittest.cc

Issue 13834009: SPDY - Re-land greedy read support for SpdySession (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: histograms to track bytes_read during init 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
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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 11220 matching lines...) Expand 10 before | Expand all | Expand 10 after
11231 EXPECT_EQ(ERR_IO_PENDING, 11231 EXPECT_EQ(ERR_IO_PENDING,
11232 trans2.Start(&request2, callback2.callback(), BoundNetLog())); 11232 trans2.Start(&request2, callback2.callback(), BoundNetLog()));
11233 MessageLoop::current()->RunUntilIdle(); 11233 MessageLoop::current()->RunUntilIdle();
11234 data2->RunFor(3); 11234 data2->RunFor(3);
11235 11235
11236 ASSERT_TRUE(callback2.have_result()); 11236 ASSERT_TRUE(callback2.have_result());
11237 EXPECT_EQ(OK, callback2.WaitForResult()); 11237 EXPECT_EQ(OK, callback2.WaitForResult());
11238 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); 11238 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy);
11239 } 11239 }
11240 11240
11241 // Test to verify that a failed socket read (due to an ERR_CONNECTION_CLOSED
11242 // error) in SPDY session, removes the socket from pool and closes the SPDY
11243 // session. Verify that new url's from the same HttpNetworkSession (and a new
11244 // SpdySession) do work. http://crbug.com/224701
11245 TEST_F(HttpNetworkTransactionSpdy3Test, ErrorSocketNotConnected) {
11246 const std::string https_url = "https://www.google.com/";
11247
11248 MockRead reads1[] = {
11249 MockRead(SYNCHRONOUS, ERR_CONNECTION_CLOSED, 0)
11250 };
11251
11252 scoped_ptr<DeterministicSocketData> data1(
11253 new DeterministicSocketData(reads1, arraysize(reads1), NULL, 0));
11254 data1->SetStop(1);
11255
11256 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(https_url.c_str(),
11257 false, 1, MEDIUM));
11258 MockWrite writes2[] = {
11259 CreateMockWrite(*req2, 0),
11260 };
11261
11262 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1));
11263 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(1, true));
11264 MockRead reads2[] = {
11265 CreateMockRead(*resp2, 1),
11266 CreateMockRead(*body2, 2),
11267 MockRead(ASYNC, OK, 3) // EOF
11268 };
11269
11270 scoped_ptr<DeterministicSocketData> data2(
11271 new DeterministicSocketData(reads2, arraysize(reads2),
11272 writes2, arraysize(writes2)));
11273
11274 SpdySessionDependencies session_deps;
11275 SSLSocketDataProvider ssl1(ASYNC, OK);
11276 ssl1.SetNextProto(kProtoSPDY3);
11277 session_deps.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl1);
11278 session_deps.deterministic_socket_factory->AddSocketDataProvider(data1.get());
11279
11280 SSLSocketDataProvider ssl2(ASYNC, OK);
11281 ssl2.SetNextProto(kProtoSPDY3);
11282 session_deps.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2);
11283 session_deps.deterministic_socket_factory->AddSocketDataProvider(data2.get());
11284
11285 scoped_refptr<HttpNetworkSession> session(
11286 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps));
11287
11288 // Start the first transaction to set up the SpdySession and verify that
11289 // connection was closed.
11290 HttpRequestInfo request1;
11291 request1.method = "GET";
11292 request1.url = GURL(https_url);
11293 request1.load_flags = 0;
11294 HttpNetworkTransaction trans1(MEDIUM, session);
11295 TestCompletionCallback callback1;
11296 EXPECT_EQ(ERR_IO_PENDING,
11297 trans1.Start(&request1, callback1.callback(), BoundNetLog()));
11298 MessageLoop::current()->RunUntilIdle();
11299 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback1.WaitForResult());
11300
11301 // Now, start the second request and make sure it succeeds.
11302 HttpRequestInfo request2;
11303 request2.method = "GET";
11304 request2.url = GURL(https_url);
11305 request2.load_flags = 0;
11306 HttpNetworkTransaction trans2(MEDIUM, session);
11307 TestCompletionCallback callback2;
11308 EXPECT_EQ(ERR_IO_PENDING,
11309 trans2.Start(&request2, callback2.callback(), BoundNetLog()));
11310 MessageLoop::current()->RunUntilIdle();
11311 data2->RunFor(3);
11312
11313 ASSERT_TRUE(callback2.have_result());
11314 EXPECT_EQ(OK, callback2.WaitForResult());
11315 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy);
11316 }
11317
11241 } // namespace net 11318 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698