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

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

Issue 15701009: [SPDY] Add a SpdyStreamType enum and use it for SpdyStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK -> DCHECK Created 7 years, 7 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/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 "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 158 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
159 159
160 CreateDeterministicNetworkSession(); 160 CreateDeterministicNetworkSession();
161 161
162 scoped_refptr<SpdySession> session = CreateInitializedSession(); 162 scoped_refptr<SpdySession> session = CreateInitializedSession();
163 163
164 EXPECT_EQ(2, session->GetProtocolVersion()); 164 EXPECT_EQ(2, session->GetProtocolVersion());
165 165
166 GURL url("http://www.google.com"); 166 GURL url("http://www.google.com");
167 base::WeakPtr<SpdyStream> spdy_stream1 = 167 base::WeakPtr<SpdyStream> spdy_stream1 =
168 CreateStreamSynchronously(session, url, MEDIUM, BoundNetLog()); 168 CreateStreamSynchronously(
169 SPDY_BIDIRECTIONAL_STREAM, session, url, MEDIUM, BoundNetLog());
169 170
170 base::WeakPtr<SpdyStream> spdy_stream2 = 171 base::WeakPtr<SpdyStream> spdy_stream2 =
171 CreateStreamSynchronously(session, url, MEDIUM, BoundNetLog()); 172 CreateStreamSynchronously(
173 SPDY_BIDIRECTIONAL_STREAM, session, url, MEDIUM, BoundNetLog());
172 174
173 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 175 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
174 (*headers)["method"] = "GET"; 176 (*headers)["method"] = "GET";
175 (*headers)["scheme"] = url.scheme(); 177 (*headers)["scheme"] = url.scheme();
176 (*headers)["host"] = url.host(); 178 (*headers)["host"] = url.host();
177 (*headers)["url"] = url.path(); 179 (*headers)["url"] = url.path();
178 (*headers)["version"] = "HTTP/1.1"; 180 (*headers)["version"] = "HTTP/1.1";
179 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock); 181 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock);
180 *headers2 = *headers; 182 *headers2 = *headers;
181 183
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 session_deps_.socket_factory->AddSocketDataProvider(&data); 234 session_deps_.socket_factory->AddSocketDataProvider(&data);
233 235
234 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 236 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
235 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 237 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
236 238
237 CreateNetworkSession(); 239 CreateNetworkSession();
238 240
239 scoped_refptr<SpdySession> session = CreateInitializedSession(); 241 scoped_refptr<SpdySession> session = CreateInitializedSession();
240 242
241 base::WeakPtr<SpdyStream> spdy_stream1 = 243 base::WeakPtr<SpdyStream> spdy_stream1 =
242 CreateStreamSynchronously(session, test_url_, MEDIUM, BoundNetLog()); 244 CreateStreamSynchronously(
245 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM, BoundNetLog());
243 ASSERT_TRUE(spdy_stream1.get() != NULL); 246 ASSERT_TRUE(spdy_stream1.get() != NULL);
244 test::StreamDelegateSendImmediate delegate(spdy_stream1, NULL); 247 test::StreamDelegateSendImmediate delegate(spdy_stream1, NULL);
245 spdy_stream1->SetDelegate(&delegate); 248 spdy_stream1->SetDelegate(&delegate);
246 249
247 base::TimeTicks before_ping_time = base::TimeTicks::Now(); 250 base::TimeTicks before_ping_time = base::TimeTicks::Now();
248 251
249 session->set_connection_at_risk_of_loss_time( 252 session->set_connection_at_risk_of_loss_time(
250 base::TimeDelta::FromSeconds(-1)); 253 base::TimeDelta::FromSeconds(-1));
251 session->set_hung_interval(base::TimeDelta::FromMilliseconds(50)); 254 session->set_hung_interval(base::TimeDelta::FromMilliseconds(50));
252 255
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 session_deps_.socket_factory->AddSocketDataProvider(&data); 289 session_deps_.socket_factory->AddSocketDataProvider(&data);
287 290
288 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 291 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
289 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 292 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
290 293
291 CreateNetworkSession(); 294 CreateNetworkSession();
292 295
293 scoped_refptr<SpdySession> session = CreateInitializedSession(); 296 scoped_refptr<SpdySession> session = CreateInitializedSession();
294 297
295 base::WeakPtr<SpdyStream> spdy_stream1 = 298 base::WeakPtr<SpdyStream> spdy_stream1 =
296 CreateStreamSynchronously(session, test_url_, MEDIUM, BoundNetLog()); 299 CreateStreamSynchronously(
300 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM, BoundNetLog());
297 ASSERT_TRUE(spdy_stream1.get() != NULL); 301 ASSERT_TRUE(spdy_stream1.get() != NULL);
298 test::StreamDelegateSendImmediate delegate(spdy_stream1, NULL); 302 test::StreamDelegateSendImmediate delegate(spdy_stream1, NULL);
299 spdy_stream1->SetDelegate(&delegate); 303 spdy_stream1->SetDelegate(&delegate);
300 304
301 // Flush the SpdySession::OnReadComplete() task. 305 // Flush the SpdySession::OnReadComplete() task.
302 base::MessageLoop::current()->RunUntilIdle(); 306 base::MessageLoop::current()->RunUntilIdle();
303 307
304 EXPECT_FALSE(spdy_session_pool_->HasSession(key_)); 308 EXPECT_FALSE(spdy_session_pool_->HasSession(key_));
305 309
306 // Delete the session. 310 // Delete the session.
(...skipping 15 matching lines...) Expand all
322 // Give the session a SPDY2 framer. 326 // Give the session a SPDY2 framer.
323 session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(SPDY2, false)); 327 session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(SPDY2, false));
324 328
325 // Create the associated stream and add to active streams. 329 // Create the associated stream and add to active streams.
326 scoped_ptr<SpdyHeaderBlock> request_headers(new SpdyHeaderBlock); 330 scoped_ptr<SpdyHeaderBlock> request_headers(new SpdyHeaderBlock);
327 (*request_headers)["scheme"] = "http"; 331 (*request_headers)["scheme"] = "http";
328 (*request_headers)["host"] = "www.google.com"; 332 (*request_headers)["host"] = "www.google.com";
329 (*request_headers)["url"] = "/"; 333 (*request_headers)["url"] = "/";
330 334
331 scoped_ptr<SpdyStream> stream( 335 scoped_ptr<SpdyStream> stream(
332 new SpdyStream(session, std::string(), DEFAULT_PRIORITY, 336 new SpdyStream(SPDY_REQUEST_RESPONSE_STREAM,
337 session, std::string(), DEFAULT_PRIORITY,
333 kSpdyStreamInitialWindowSize, 338 kSpdyStreamInitialWindowSize,
334 kSpdyStreamInitialWindowSize, 339 kSpdyStreamInitialWindowSize,
335 false, session->net_log_)); 340 session->net_log_));
336 stream->SendRequestHeaders(request_headers.Pass(), NO_MORE_DATA_TO_SEND); 341 stream->SendRequestHeaders(request_headers.Pass(), NO_MORE_DATA_TO_SEND);
337 SpdyStream* stream_ptr = stream.get(); 342 SpdyStream* stream_ptr = stream.get();
338 session->InsertCreatedStream(stream.Pass()); 343 session->InsertCreatedStream(stream.Pass());
339 stream = session->ActivateCreatedStream(stream_ptr); 344 stream = session->ActivateCreatedStream(stream_ptr);
340 session->InsertActivatedStream(stream.Pass()); 345 session->InsertActivatedStream(stream.Pass());
341 346
342 SpdyHeaderBlock headers; 347 SpdyHeaderBlock headers;
343 headers["url"] = "http://www.google.com/a.dat"; 348 headers["url"] = "http://www.google.com/a.dat";
344 session->OnSynStream(2, 1, 0, 0, true, false, headers); 349 session->OnSynStream(2, 1, 0, 0, true, false, headers);
345 350
346 // Verify that there is one unclaimed push stream. 351 // Verify that there is one unclaimed push stream.
347 EXPECT_EQ(1u, session->num_unclaimed_pushed_streams()); 352 EXPECT_EQ(1u, session->num_unclaimed_pushed_streams());
348 SpdySession::PushedStreamMap::iterator iter = 353 SpdySession::PushedStreamMap::iterator iter =
349 session->unclaimed_pushed_streams_.find("http://www.google.com/a.dat"); 354 session->unclaimed_pushed_streams_.find("http://www.google.com/a.dat");
350 EXPECT_TRUE(session->unclaimed_pushed_streams_.end() != iter); 355 EXPECT_TRUE(session->unclaimed_pushed_streams_.end() != iter);
351 356
352 // Shift time. 357 // Shift time.
353 g_delta_seconds = 301; 358 g_delta_seconds = 301;
354 359
355 headers["url"] = "http://www.google.com/b.dat"; 360 headers["url"] = "http://www.google.com/b.dat";
356 session->OnSynStream(4, 1, 0, 0, true, false, headers); 361 session->OnSynStream(4, 1, 0, 0, true, false, headers);
357 362
358 // Verify that the second pushed stream evicted the first pushed stream. 363 // Verify that the second pushed stream evicted the first pushed stream.
(...skipping 24 matching lines...) Expand all
383 session_deps_.socket_factory->AddSocketDataProvider(&data); 388 session_deps_.socket_factory->AddSocketDataProvider(&data);
384 389
385 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 390 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
386 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 391 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
387 392
388 CreateNetworkSession(); 393 CreateNetworkSession();
389 394
390 scoped_refptr<SpdySession> session = CreateInitializedSession(); 395 scoped_refptr<SpdySession> session = CreateInitializedSession();
391 396
392 base::WeakPtr<SpdyStream> spdy_stream1 = 397 base::WeakPtr<SpdyStream> spdy_stream1 =
393 CreateStreamSynchronously(session, test_url_, MEDIUM, BoundNetLog()); 398 CreateStreamSynchronously(
399 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM, BoundNetLog());
394 ASSERT_TRUE(spdy_stream1.get() != NULL); 400 ASSERT_TRUE(spdy_stream1.get() != NULL);
395 test::StreamDelegateSendImmediate delegate(spdy_stream1, NULL); 401 test::StreamDelegateSendImmediate delegate(spdy_stream1, NULL);
396 spdy_stream1->SetDelegate(&delegate); 402 spdy_stream1->SetDelegate(&delegate);
397 403
398 session->set_connection_at_risk_of_loss_time(base::TimeDelta::FromSeconds(0)); 404 session->set_connection_at_risk_of_loss_time(base::TimeDelta::FromSeconds(0));
399 session->set_hung_interval(base::TimeDelta::FromSeconds(0)); 405 session->set_hung_interval(base::TimeDelta::FromSeconds(0));
400 406
401 // Send a PING frame. 407 // Send a PING frame.
402 session->WritePingFrame(1); 408 session->WritePingFrame(1);
403 EXPECT_LT(0, session->pings_in_flight()); 409 EXPECT_LT(0, session->pings_in_flight());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 HostPortPair test_host_port_pair1(kTestHost1, 80); 448 HostPortPair test_host_port_pair1(kTestHost1, 80);
443 SpdySessionKey key1(test_host_port_pair1, ProxyServer::Direct(), 449 SpdySessionKey key1(test_host_port_pair1, ProxyServer::Direct(),
444 kPrivacyModeDisabled); 450 kPrivacyModeDisabled);
445 scoped_refptr<SpdySession> session1 = GetSession(key1); 451 scoped_refptr<SpdySession> session1 = GetSession(key1);
446 EXPECT_EQ( 452 EXPECT_EQ(
447 OK, 453 OK,
448 InitializeSession( 454 InitializeSession(
449 http_session_.get(), session1.get(), test_host_port_pair1)); 455 http_session_.get(), session1.get(), test_host_port_pair1));
450 GURL url1(kTestHost1); 456 GURL url1(kTestHost1);
451 base::WeakPtr<SpdyStream> spdy_stream1 = 457 base::WeakPtr<SpdyStream> spdy_stream1 =
452 CreateStreamSynchronously(session1, url1, MEDIUM, BoundNetLog()); 458 CreateStreamSynchronously(
459 SPDY_BIDIRECTIONAL_STREAM, session1, url1, MEDIUM, BoundNetLog());
453 ASSERT_TRUE(spdy_stream1.get() != NULL); 460 ASSERT_TRUE(spdy_stream1.get() != NULL);
454 461
455 // Set up session 2 462 // Set up session 2
456 session_deps_.socket_factory->AddSocketDataProvider(&data); 463 session_deps_.socket_factory->AddSocketDataProvider(&data);
457 const std::string kTestHost2("http://www.b.com"); 464 const std::string kTestHost2("http://www.b.com");
458 HostPortPair test_host_port_pair2(kTestHost2, 80); 465 HostPortPair test_host_port_pair2(kTestHost2, 80);
459 SpdySessionKey key2(test_host_port_pair2, ProxyServer::Direct(), 466 SpdySessionKey key2(test_host_port_pair2, ProxyServer::Direct(),
460 kPrivacyModeDisabled); 467 kPrivacyModeDisabled);
461 scoped_refptr<SpdySession> session2 = GetSession(key2); 468 scoped_refptr<SpdySession> session2 = GetSession(key2);
462 EXPECT_EQ( 469 EXPECT_EQ(
463 OK, 470 OK,
464 InitializeSession( 471 InitializeSession(
465 http_session_.get(), session2.get(), test_host_port_pair2)); 472 http_session_.get(), session2.get(), test_host_port_pair2));
466 GURL url2(kTestHost2); 473 GURL url2(kTestHost2);
467 base::WeakPtr<SpdyStream> spdy_stream2 = 474 base::WeakPtr<SpdyStream> spdy_stream2 =
468 CreateStreamSynchronously(session2, url2, MEDIUM, BoundNetLog()); 475 CreateStreamSynchronously(
476 SPDY_BIDIRECTIONAL_STREAM, session2, url2, MEDIUM, BoundNetLog());
469 ASSERT_TRUE(spdy_stream2.get() != NULL); 477 ASSERT_TRUE(spdy_stream2.get() != NULL);
470 478
471 // Set up session 3 479 // Set up session 3
472 session_deps_.socket_factory->AddSocketDataProvider(&data); 480 session_deps_.socket_factory->AddSocketDataProvider(&data);
473 const std::string kTestHost3("http://www.c.com"); 481 const std::string kTestHost3("http://www.c.com");
474 HostPortPair test_host_port_pair3(kTestHost3, 80); 482 HostPortPair test_host_port_pair3(kTestHost3, 80);
475 SpdySessionKey key3(test_host_port_pair3, ProxyServer::Direct(), 483 SpdySessionKey key3(test_host_port_pair3, ProxyServer::Direct(),
476 kPrivacyModeDisabled); 484 kPrivacyModeDisabled);
477 scoped_refptr<SpdySession> session3 = GetSession(key3); 485 scoped_refptr<SpdySession> session3 = GetSession(key3);
478 EXPECT_EQ( 486 EXPECT_EQ(
479 OK, 487 OK,
480 InitializeSession( 488 InitializeSession(
481 http_session_.get(), session3.get(), test_host_port_pair3)); 489 http_session_.get(), session3.get(), test_host_port_pair3));
482 GURL url3(kTestHost3); 490 GURL url3(kTestHost3);
483 base::WeakPtr<SpdyStream> spdy_stream3 = 491 base::WeakPtr<SpdyStream> spdy_stream3 =
484 CreateStreamSynchronously(session3, url3, MEDIUM, BoundNetLog()); 492 CreateStreamSynchronously(
493 SPDY_BIDIRECTIONAL_STREAM, session3, url3, MEDIUM, BoundNetLog());
485 ASSERT_TRUE(spdy_stream3.get() != NULL); 494 ASSERT_TRUE(spdy_stream3.get() != NULL);
486 495
487 // All sessions are active and not closed 496 // All sessions are active and not closed
488 EXPECT_TRUE(session1->is_active()); 497 EXPECT_TRUE(session1->is_active());
489 EXPECT_FALSE(session1->IsClosed()); 498 EXPECT_FALSE(session1->IsClosed());
490 EXPECT_TRUE(session2->is_active()); 499 EXPECT_TRUE(session2->is_active());
491 EXPECT_FALSE(session2->IsClosed()); 500 EXPECT_FALSE(session2->IsClosed());
492 EXPECT_TRUE(session3->is_active()); 501 EXPECT_TRUE(session3->is_active());
493 EXPECT_FALSE(session3->IsClosed()); 502 EXPECT_FALSE(session3->IsClosed());
494 503
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 spdy_session_pool_->http_server_properties()->SetSpdySetting( 586 spdy_session_pool_->http_server_properties()->SetSpdySetting(
578 test_host_port_pair_, 587 test_host_port_pair_,
579 kSpdySettingsIds1, 588 kSpdySettingsIds1,
580 SETTINGS_FLAG_PLEASE_PERSIST, 589 SETTINGS_FLAG_PLEASE_PERSIST,
581 1); 590 1);
582 591
583 scoped_refptr<SpdySession> session = CreateInitializedSession(); 592 scoped_refptr<SpdySession> session = CreateInitializedSession();
584 593
585 // Create 2 streams. First will succeed. Second will be pending. 594 // Create 2 streams. First will succeed. Second will be pending.
586 base::WeakPtr<SpdyStream> spdy_stream1 = 595 base::WeakPtr<SpdyStream> spdy_stream1 =
587 CreateStreamSynchronously(session, test_url_, MEDIUM, BoundNetLog()); 596 CreateStreamSynchronously(
597 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM, BoundNetLog());
588 ASSERT_TRUE(spdy_stream1.get() != NULL); 598 ASSERT_TRUE(spdy_stream1.get() != NULL);
589 599
590 StreamReleaserCallback stream_releaser; 600 StreamReleaserCallback stream_releaser;
591 SpdyStreamRequest request; 601 SpdyStreamRequest request;
592 ASSERT_EQ(ERR_IO_PENDING, 602 ASSERT_EQ(ERR_IO_PENDING,
593 request.StartRequest(session, test_url_, MEDIUM, 603 request.StartRequest(
594 BoundNetLog(), 604 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM,
595 stream_releaser.MakeCallback(&request))); 605 BoundNetLog(),
606 stream_releaser.MakeCallback(&request)));
596 607
597 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 608 EXPECT_EQ(OK, stream_releaser.WaitForResult());
598 } 609 }
599 610
600 // Start with max concurrent streams set to 1 (that is persisted). Receive a 611 // Start with max concurrent streams set to 1 (that is persisted). Receive a
601 // settings frame setting max concurrent streams to 2 and which also clears the 612 // settings frame setting max concurrent streams to 2 and which also clears the
602 // persisted data. Verify that persisted data is correct. 613 // persisted data. Verify that persisted data is correct.
603 TEST_F(SpdySessionSpdy2Test, ClearSettings) { 614 TEST_F(SpdySessionSpdy2Test, ClearSettings) {
604 session_deps_.host_resolver->set_synchronous_mode(true); 615 session_deps_.host_resolver->set_synchronous_mode(true);
605 616
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 SETTINGS_FLAG_PLEASE_PERSIST, 648 SETTINGS_FLAG_PLEASE_PERSIST,
638 1); 649 1);
639 650
640 EXPECT_EQ(1u, spdy_session_pool_->http_server_properties()->GetSpdySettings( 651 EXPECT_EQ(1u, spdy_session_pool_->http_server_properties()->GetSpdySettings(
641 test_host_port_pair_).size()); 652 test_host_port_pair_).size());
642 653
643 scoped_refptr<SpdySession> session = CreateInitializedSession(); 654 scoped_refptr<SpdySession> session = CreateInitializedSession();
644 655
645 // Create 2 streams. First will succeed. Second will be pending. 656 // Create 2 streams. First will succeed. Second will be pending.
646 base::WeakPtr<SpdyStream> spdy_stream1 = 657 base::WeakPtr<SpdyStream> spdy_stream1 =
647 CreateStreamSynchronously(session, test_url_, MEDIUM, BoundNetLog()); 658 CreateStreamSynchronously(
659 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM, BoundNetLog());
648 ASSERT_TRUE(spdy_stream1.get() != NULL); 660 ASSERT_TRUE(spdy_stream1.get() != NULL);
649 661
650 StreamReleaserCallback stream_releaser; 662 StreamReleaserCallback stream_releaser;
651 SpdyStreamRequest request; 663 SpdyStreamRequest request;
652 ASSERT_EQ(ERR_IO_PENDING, 664 ASSERT_EQ(ERR_IO_PENDING,
653 request.StartRequest(session, test_url_, MEDIUM, 665 request.StartRequest(
654 BoundNetLog(), 666 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM,
655 stream_releaser.MakeCallback(&request))); 667 BoundNetLog(),
668 stream_releaser.MakeCallback(&request)));
656 669
657 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 670 EXPECT_EQ(OK, stream_releaser.WaitForResult());
658 671
659 // Make sure that persisted data is cleared. 672 // Make sure that persisted data is cleared.
660 EXPECT_EQ(0u, spdy_session_pool_->http_server_properties()->GetSpdySettings( 673 EXPECT_EQ(0u, spdy_session_pool_->http_server_properties()->GetSpdySettings(
661 test_host_port_pair_).size()); 674 test_host_port_pair_).size());
662 675
663 // Make sure session's max_concurrent_streams is 2. 676 // Make sure session's max_concurrent_streams is 2.
664 EXPECT_EQ(2u, session->max_concurrent_streams()); 677 EXPECT_EQ(2u, session->max_concurrent_streams());
665 678
(...skipping 26 matching lines...) Expand all
692 spdy_session_pool_->http_server_properties()->SetSpdySetting( 705 spdy_session_pool_->http_server_properties()->SetSpdySetting(
693 test_host_port_pair_, 706 test_host_port_pair_,
694 SETTINGS_MAX_CONCURRENT_STREAMS, 707 SETTINGS_MAX_CONCURRENT_STREAMS,
695 SETTINGS_FLAG_PLEASE_PERSIST, 708 SETTINGS_FLAG_PLEASE_PERSIST,
696 1); 709 1);
697 710
698 scoped_refptr<SpdySession> session = CreateInitializedSession(); 711 scoped_refptr<SpdySession> session = CreateInitializedSession();
699 712
700 // Create 2 streams. First will succeed. Second will be pending. 713 // Create 2 streams. First will succeed. Second will be pending.
701 base::WeakPtr<SpdyStream> spdy_stream1 = 714 base::WeakPtr<SpdyStream> spdy_stream1 =
702 CreateStreamSynchronously(session, test_url_, MEDIUM, BoundNetLog()); 715 CreateStreamSynchronously(
716 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM, BoundNetLog());
703 ASSERT_TRUE(spdy_stream1.get() != NULL); 717 ASSERT_TRUE(spdy_stream1.get() != NULL);
704 718
705 // Use scoped_ptr to let us invalidate the memory when we want to, to trigger 719 // Use scoped_ptr to let us invalidate the memory when we want to, to trigger
706 // a valgrind error if the callback is invoked when it's not supposed to be. 720 // a valgrind error if the callback is invoked when it's not supposed to be.
707 scoped_ptr<TestCompletionCallback> callback(new TestCompletionCallback); 721 scoped_ptr<TestCompletionCallback> callback(new TestCompletionCallback);
708 722
709 SpdyStreamRequest request; 723 SpdyStreamRequest request;
710 ASSERT_EQ(ERR_IO_PENDING, 724 ASSERT_EQ(ERR_IO_PENDING,
711 request.StartRequest(session, test_url_, MEDIUM, 725 request.StartRequest(
712 BoundNetLog(), 726 SPDY_BIDIRECTIONAL_STREAM, session, test_url_, MEDIUM,
713 callback->callback())); 727 BoundNetLog(),
728 callback->callback()));
714 729
715 // Release the first one, this will allow the second to be created. 730 // Release the first one, this will allow the second to be created.
716 spdy_stream1->Cancel(); 731 spdy_stream1->Cancel();
717 EXPECT_EQ(NULL, spdy_stream1.get()); 732 EXPECT_EQ(NULL, spdy_stream1.get());
718 733
719 request.CancelRequest(); 734 request.CancelRequest();
720 callback.reset(); 735 callback.reset();
721 736
722 // Should not crash when running the pending callback. 737 // Should not crash when running the pending callback.
723 base::MessageLoop::current()->RunUntilIdle(); 738 base::MessageLoop::current()->RunUntilIdle();
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 session = NULL; 992 session = NULL;
978 spdy_session_pool->Remove(session2); 993 spdy_session_pool->Remove(session2);
979 session2 = NULL; 994 session2 = NULL;
980 break; 995 break;
981 case SPDY_POOL_CLOSE_CURRENT_SESSIONS: 996 case SPDY_POOL_CLOSE_CURRENT_SESSIONS:
982 spdy_session_pool->CloseCurrentSessions(net::ERR_ABORTED); 997 spdy_session_pool->CloseCurrentSessions(net::ERR_ABORTED);
983 break; 998 break;
984 case SPDY_POOL_CLOSE_IDLE_SESSIONS: 999 case SPDY_POOL_CLOSE_IDLE_SESSIONS:
985 GURL url(test_hosts[0].url); 1000 GURL url(test_hosts[0].url);
986 base::WeakPtr<SpdyStream> spdy_stream = 1001 base::WeakPtr<SpdyStream> spdy_stream =
987 CreateStreamSynchronously(session, url, MEDIUM, BoundNetLog()); 1002 CreateStreamSynchronously(
1003 SPDY_BIDIRECTIONAL_STREAM, session, url, MEDIUM, BoundNetLog());
988 GURL url1(test_hosts[1].url); 1004 GURL url1(test_hosts[1].url);
989 base::WeakPtr<SpdyStream> spdy_stream1 = 1005 base::WeakPtr<SpdyStream> spdy_stream1 =
990 CreateStreamSynchronously(session1, url1, MEDIUM, BoundNetLog()); 1006 CreateStreamSynchronously(
1007 SPDY_BIDIRECTIONAL_STREAM, session1, url1, MEDIUM, BoundNetLog());
991 GURL url2(test_hosts[2].url); 1008 GURL url2(test_hosts[2].url);
992 base::WeakPtr<SpdyStream> spdy_stream2 = 1009 base::WeakPtr<SpdyStream> spdy_stream2 =
993 CreateStreamSynchronously(session2, url2, MEDIUM, BoundNetLog()); 1010 CreateStreamSynchronously(
1011 SPDY_BIDIRECTIONAL_STREAM, session2, url2, MEDIUM, BoundNetLog());
994 1012
995 // Close streams to make spdy_session and spdy_session1 inactive. 1013 // Close streams to make spdy_session and spdy_session1 inactive.
996 session->CloseCreatedStream(spdy_stream, OK); 1014 session->CloseCreatedStream(spdy_stream, OK);
997 EXPECT_EQ(NULL, spdy_stream.get()); 1015 EXPECT_EQ(NULL, spdy_stream.get());
998 session1->CloseCreatedStream(spdy_stream1, OK); 1016 session1->CloseCreatedStream(spdy_stream1, OK);
999 EXPECT_EQ(NULL, spdy_stream1.get()); 1017 EXPECT_EQ(NULL, spdy_stream1.get());
1000 1018
1001 // Check spdy_session and spdy_session1 are not closed. 1019 // Check spdy_session and spdy_session1 are not closed.
1002 EXPECT_FALSE(session->is_active()); 1020 EXPECT_FALSE(session->is_active());
1003 EXPECT_FALSE(session->IsClosed()); 1021 EXPECT_FALSE(session->IsClosed());
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 1163 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1146 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 1164 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
1147 1165
1148 CreateNetworkSession(); 1166 CreateNetworkSession();
1149 1167
1150 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1168 scoped_refptr<SpdySession> session = CreateInitializedSession();
1151 1169
1152 GURL url("http://www.google.com"); 1170 GURL url("http://www.google.com");
1153 1171
1154 base::WeakPtr<SpdyStream> spdy_stream1 = 1172 base::WeakPtr<SpdyStream> spdy_stream1 =
1155 CreateStreamSynchronously(session, url, LOWEST, BoundNetLog()); 1173 CreateStreamSynchronously(
1174 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, BoundNetLog());
1156 ASSERT_TRUE(spdy_stream1.get() != NULL); 1175 ASSERT_TRUE(spdy_stream1.get() != NULL);
1157 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1176 EXPECT_EQ(0u, spdy_stream1->stream_id());
1158 test::StreamDelegateDoNothing delegate1(spdy_stream1); 1177 test::StreamDelegateDoNothing delegate1(spdy_stream1);
1159 spdy_stream1->SetDelegate(&delegate1); 1178 spdy_stream1->SetDelegate(&delegate1);
1160 1179
1161 base::WeakPtr<SpdyStream> spdy_stream2 = 1180 base::WeakPtr<SpdyStream> spdy_stream2 =
1162 CreateStreamSynchronously(session, url, HIGHEST, BoundNetLog()); 1181 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
1182 session, url, HIGHEST, BoundNetLog());
1163 ASSERT_TRUE(spdy_stream2.get() != NULL); 1183 ASSERT_TRUE(spdy_stream2.get() != NULL);
1164 EXPECT_EQ(0u, spdy_stream2->stream_id()); 1184 EXPECT_EQ(0u, spdy_stream2->stream_id());
1165 test::StreamDelegateDoNothing delegate2(spdy_stream2); 1185 test::StreamDelegateDoNothing delegate2(spdy_stream2);
1166 spdy_stream2->SetDelegate(&delegate2); 1186 spdy_stream2->SetDelegate(&delegate2);
1167 1187
1168 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1188 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1169 (*headers)["method"] = "GET"; 1189 (*headers)["method"] = "GET";
1170 (*headers)["scheme"] = url.scheme(); 1190 (*headers)["scheme"] = url.scheme();
1171 (*headers)["host"] = url.host(); 1191 (*headers)["host"] = url.host();
1172 (*headers)["url"] = url.path(); 1192 (*headers)["url"] = url.path();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 1234
1215 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 1235 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1216 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 1236 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
1217 1237
1218 CreateDeterministicNetworkSession(); 1238 CreateDeterministicNetworkSession();
1219 1239
1220 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1240 scoped_refptr<SpdySession> session = CreateInitializedSession();
1221 1241
1222 GURL url1("http://www.google.com"); 1242 GURL url1("http://www.google.com");
1223 base::WeakPtr<SpdyStream> spdy_stream1 = 1243 base::WeakPtr<SpdyStream> spdy_stream1 =
1224 CreateStreamSynchronously(session, url1, HIGHEST, BoundNetLog()); 1244 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1245 session, url1, HIGHEST, BoundNetLog());
1225 ASSERT_TRUE(spdy_stream1.get() != NULL); 1246 ASSERT_TRUE(spdy_stream1.get() != NULL);
1226 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1247 EXPECT_EQ(0u, spdy_stream1->stream_id());
1227 test::StreamDelegateDoNothing delegate1(spdy_stream1); 1248 test::StreamDelegateDoNothing delegate1(spdy_stream1);
1228 spdy_stream1->SetDelegate(&delegate1); 1249 spdy_stream1->SetDelegate(&delegate1);
1229 1250
1230 GURL url2("http://www.google.com"); 1251 GURL url2("http://www.google.com");
1231 base::WeakPtr<SpdyStream> spdy_stream2 = 1252 base::WeakPtr<SpdyStream> spdy_stream2 =
1232 CreateStreamSynchronously(session, url2, LOWEST, BoundNetLog()); 1253 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1254 session, url2, LOWEST, BoundNetLog());
1233 ASSERT_TRUE(spdy_stream2.get() != NULL); 1255 ASSERT_TRUE(spdy_stream2.get() != NULL);
1234 EXPECT_EQ(0u, spdy_stream2->stream_id()); 1256 EXPECT_EQ(0u, spdy_stream2->stream_id());
1235 test::StreamDelegateDoNothing delegate2(spdy_stream2); 1257 test::StreamDelegateDoNothing delegate2(spdy_stream2);
1236 spdy_stream2->SetDelegate(&delegate2); 1258 spdy_stream2->SetDelegate(&delegate2);
1237 1259
1238 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1260 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1239 (*headers)["method"] = "GET"; 1261 (*headers)["method"] = "GET";
1240 (*headers)["scheme"] = url1.scheme(); 1262 (*headers)["scheme"] = url1.scheme();
1241 (*headers)["host"] = url1.host(); 1263 (*headers)["host"] = url1.host();
1242 (*headers)["url"] = url1.path(); 1264 (*headers)["url"] = url1.path();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1309
1288 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 1310 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1289 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 1311 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
1290 1312
1291 CreateDeterministicNetworkSession(); 1313 CreateDeterministicNetworkSession();
1292 1314
1293 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1315 scoped_refptr<SpdySession> session = CreateInitializedSession();
1294 1316
1295 GURL url1("http://www.google.com"); 1317 GURL url1("http://www.google.com");
1296 base::WeakPtr<SpdyStream> spdy_stream1 = 1318 base::WeakPtr<SpdyStream> spdy_stream1 =
1297 CreateStreamSynchronously(session, url1, HIGHEST, BoundNetLog()); 1319 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
1320 session, url1, HIGHEST, BoundNetLog());
1298 ASSERT_TRUE(spdy_stream1.get() != NULL); 1321 ASSERT_TRUE(spdy_stream1.get() != NULL);
1299 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1322 EXPECT_EQ(0u, spdy_stream1->stream_id());
1300 1323
1301 GURL url2("http://www.google.com"); 1324 GURL url2("http://www.google.com");
1302 base::WeakPtr<SpdyStream> spdy_stream2 = 1325 base::WeakPtr<SpdyStream> spdy_stream2 =
1303 CreateStreamSynchronously(session, url2, LOWEST, BoundNetLog()); 1326 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
1327 session, url2, LOWEST, BoundNetLog());
1304 ASSERT_TRUE(spdy_stream2.get() != NULL); 1328 ASSERT_TRUE(spdy_stream2.get() != NULL);
1305 EXPECT_EQ(0u, spdy_stream2->stream_id()); 1329 EXPECT_EQ(0u, spdy_stream2->stream_id());
1306 1330
1307 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1331 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1308 (*headers)["method"] = "GET"; 1332 (*headers)["method"] = "GET";
1309 (*headers)["scheme"] = url1.scheme(); 1333 (*headers)["scheme"] = url1.scheme();
1310 (*headers)["host"] = url1.host(); 1334 (*headers)["host"] = url1.host();
1311 (*headers)["url"] = url1.path(); 1335 (*headers)["url"] = url1.path();
1312 (*headers)["version"] = "HTTP/1.1"; 1336 (*headers)["version"] = "HTTP/1.1";
1313 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock); 1337 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 1557
1534 CreateDeterministicNetworkSession(); 1558 CreateDeterministicNetworkSession();
1535 1559
1536 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1560 scoped_refptr<SpdySession> session = CreateInitializedSession();
1537 1561
1538 // Read the settings frame. 1562 // Read the settings frame.
1539 data.RunFor(1); 1563 data.RunFor(1);
1540 1564
1541 GURL url1("http://www.google.com"); 1565 GURL url1("http://www.google.com");
1542 base::WeakPtr<SpdyStream> spdy_stream1 = 1566 base::WeakPtr<SpdyStream> spdy_stream1 =
1543 CreateStreamSynchronously(session, url1, LOWEST, BoundNetLog()); 1567 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1568 session, url1, LOWEST, BoundNetLog());
1544 ASSERT_TRUE(spdy_stream1.get() != NULL); 1569 ASSERT_TRUE(spdy_stream1.get() != NULL);
1545 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1570 EXPECT_EQ(0u, spdy_stream1->stream_id());
1546 test::StreamDelegateDoNothing delegate1(spdy_stream1); 1571 test::StreamDelegateDoNothing delegate1(spdy_stream1);
1547 spdy_stream1->SetDelegate(&delegate1); 1572 spdy_stream1->SetDelegate(&delegate1);
1548 1573
1549 TestCompletionCallback callback2; 1574 TestCompletionCallback callback2;
1550 GURL url2("http://www.google.com"); 1575 GURL url2("http://www.google.com");
1551 SpdyStreamRequest request2; 1576 SpdyStreamRequest request2;
1552 ASSERT_EQ(ERR_IO_PENDING, 1577 ASSERT_EQ(ERR_IO_PENDING,
1553 request2.StartRequest(session, url2, LOWEST, 1578 request2.StartRequest(SPDY_REQUEST_RESPONSE_STREAM,
1554 BoundNetLog(), 1579 session, url2, LOWEST, BoundNetLog(),
1555 callback2.callback())); 1580 callback2.callback()));
1556 1581
1557 TestCompletionCallback callback3; 1582 TestCompletionCallback callback3;
1558 GURL url3("http://www.google.com"); 1583 GURL url3("http://www.google.com");
1559 SpdyStreamRequest request3; 1584 SpdyStreamRequest request3;
1560 ASSERT_EQ(ERR_IO_PENDING, 1585 ASSERT_EQ(ERR_IO_PENDING,
1561 request3.StartRequest(session, url3, LOWEST, 1586 request3.StartRequest(SPDY_REQUEST_RESPONSE_STREAM,
1562 BoundNetLog(), 1587 session, url3, LOWEST, BoundNetLog(),
1563 callback3.callback())); 1588 callback3.callback()));
1564 1589
1565 EXPECT_EQ(1u, session->num_active_streams() + session->num_created_streams()); 1590 EXPECT_EQ(1u, session->num_active_streams() + session->num_created_streams());
1566 EXPECT_EQ(2u, session->pending_create_stream_queues(LOWEST)); 1591 EXPECT_EQ(2u, session->pending_create_stream_queues(LOWEST));
1567 1592
1568 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1593 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1569 (*headers)["method"] = "GET"; 1594 (*headers)["method"] = "GET";
1570 (*headers)["scheme"] = url1.scheme(); 1595 (*headers)["scheme"] = url1.scheme();
1571 (*headers)["host"] = url1.host(); 1596 (*headers)["host"] = url1.host();
1572 (*headers)["url"] = url1.path(); 1597 (*headers)["url"] = url1.path();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1665 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1641 test_host_port_pair_, 1666 test_host_port_pair_,
1642 SETTINGS_MAX_CONCURRENT_STREAMS, 1667 SETTINGS_MAX_CONCURRENT_STREAMS,
1643 SETTINGS_FLAG_PLEASE_PERSIST, 1668 SETTINGS_FLAG_PLEASE_PERSIST,
1644 1); 1669 1);
1645 1670
1646 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1671 scoped_refptr<SpdySession> session = CreateInitializedSession();
1647 1672
1648 GURL url1("http://www.google.com"); 1673 GURL url1("http://www.google.com");
1649 base::WeakPtr<SpdyStream> spdy_stream1 = 1674 base::WeakPtr<SpdyStream> spdy_stream1 =
1650 CreateStreamSynchronously(session, url1, LOWEST, BoundNetLog()); 1675 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
1676 session, url1, LOWEST, BoundNetLog());
1651 ASSERT_TRUE(spdy_stream1.get() != NULL); 1677 ASSERT_TRUE(spdy_stream1.get() != NULL);
1652 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1678 EXPECT_EQ(0u, spdy_stream1->stream_id());
1653 1679
1654 TestCompletionCallback callback2; 1680 TestCompletionCallback callback2;
1655 GURL url2("http://www.google.com"); 1681 GURL url2("http://www.google.com");
1656 SpdyStreamRequest request2; 1682 SpdyStreamRequest request2;
1657 ASSERT_EQ(ERR_IO_PENDING, 1683 ASSERT_EQ(ERR_IO_PENDING,
1658 request2.StartRequest(session, url2, LOWEST, 1684 request2.StartRequest(SPDY_BIDIRECTIONAL_STREAM,
1685 session, url2, LOWEST,
1659 BoundNetLog(), 1686 BoundNetLog(),
1660 callback2.callback())); 1687 callback2.callback()));
1661 1688
1662 TestCompletionCallback callback3; 1689 TestCompletionCallback callback3;
1663 GURL url3("http://www.google.com"); 1690 GURL url3("http://www.google.com");
1664 SpdyStreamRequest request3; 1691 SpdyStreamRequest request3;
1665 ASSERT_EQ(ERR_IO_PENDING, 1692 ASSERT_EQ(ERR_IO_PENDING,
1666 request3.StartRequest(session, url3, LOWEST, 1693 request3.StartRequest(SPDY_BIDIRECTIONAL_STREAM,
1694 session, url3, LOWEST,
1667 BoundNetLog(), 1695 BoundNetLog(),
1668 callback3.callback())); 1696 callback3.callback()));
1669 1697
1670 EXPECT_EQ(1u, session->num_active_streams() + session->num_created_streams()); 1698 EXPECT_EQ(1u, session->num_active_streams() + session->num_created_streams());
1671 EXPECT_EQ(2u, session->pending_create_stream_queues(LOWEST)); 1699 EXPECT_EQ(2u, session->pending_create_stream_queues(LOWEST));
1672 1700
1673 // Cancel the first stream, this will allow the second stream to be created. 1701 // Cancel the first stream, this will allow the second stream to be created.
1674 EXPECT_TRUE(spdy_stream1.get() != NULL); 1702 EXPECT_TRUE(spdy_stream1.get() != NULL);
1675 spdy_stream1->Cancel(); 1703 spdy_stream1->Cancel();
1676 EXPECT_EQ(NULL, spdy_stream1.get()); 1704 EXPECT_EQ(NULL, spdy_stream1.get());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 1831
1804 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 1832 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1805 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 1833 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
1806 1834
1807 CreateDeterministicNetworkSession(); 1835 CreateDeterministicNetworkSession();
1808 1836
1809 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1837 scoped_refptr<SpdySession> session = CreateInitializedSession();
1810 1838
1811 GURL url1("http://www.google.com"); 1839 GURL url1("http://www.google.com");
1812 base::WeakPtr<SpdyStream> spdy_stream1 = 1840 base::WeakPtr<SpdyStream> spdy_stream1 =
1813 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); 1841 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1842 session, url1, MEDIUM, BoundNetLog());
1814 ASSERT_TRUE(spdy_stream1.get() != NULL); 1843 ASSERT_TRUE(spdy_stream1.get() != NULL);
1815 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1844 EXPECT_EQ(0u, spdy_stream1->stream_id());
1816 test::StreamDelegateDoNothing delegate1(spdy_stream1); 1845 test::StreamDelegateDoNothing delegate1(spdy_stream1);
1817 spdy_stream1->SetDelegate(&delegate1); 1846 spdy_stream1->SetDelegate(&delegate1);
1818 1847
1819 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1848 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1820 (*headers)["method"] = "GET"; 1849 (*headers)["method"] = "GET";
1821 (*headers)["scheme"] = url1.scheme(); 1850 (*headers)["scheme"] = url1.scheme();
1822 (*headers)["host"] = url1.host(); 1851 (*headers)["host"] = url1.host();
1823 (*headers)["url"] = url1.path(); 1852 (*headers)["url"] = url1.path();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 1925
1897 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 1926 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1898 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 1927 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
1899 1928
1900 CreateDeterministicNetworkSession(); 1929 CreateDeterministicNetworkSession();
1901 1930
1902 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1931 scoped_refptr<SpdySession> session = CreateInitializedSession();
1903 1932
1904 GURL url1("http://www.google.com"); 1933 GURL url1("http://www.google.com");
1905 base::WeakPtr<SpdyStream> spdy_stream1 = 1934 base::WeakPtr<SpdyStream> spdy_stream1 =
1906 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); 1935 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1936 session, url1, MEDIUM, BoundNetLog());
1907 ASSERT_TRUE(spdy_stream1.get() != NULL); 1937 ASSERT_TRUE(spdy_stream1.get() != NULL);
1908 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1938 EXPECT_EQ(0u, spdy_stream1->stream_id());
1909 test::StreamDelegateDoNothing delegate1(spdy_stream1); 1939 test::StreamDelegateDoNothing delegate1(spdy_stream1);
1910 spdy_stream1->SetDelegate(&delegate1); 1940 spdy_stream1->SetDelegate(&delegate1);
1911 1941
1912 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1942 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1913 (*headers)["method"] = "GET"; 1943 (*headers)["method"] = "GET";
1914 (*headers)["scheme"] = url1.scheme(); 1944 (*headers)["scheme"] = url1.scheme();
1915 (*headers)["host"] = url1.host(); 1945 (*headers)["host"] = url1.host();
1916 (*headers)["url"] = url1.path(); 1946 (*headers)["url"] = url1.path();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 2042
2013 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 2043 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
2014 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 2044 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
2015 2045
2016 CreateDeterministicNetworkSession(); 2046 CreateDeterministicNetworkSession();
2017 2047
2018 scoped_refptr<SpdySession> session = CreateInitializedSession(); 2048 scoped_refptr<SpdySession> session = CreateInitializedSession();
2019 2049
2020 GURL url1("http://www.google.com"); 2050 GURL url1("http://www.google.com");
2021 base::WeakPtr<SpdyStream> spdy_stream1 = 2051 base::WeakPtr<SpdyStream> spdy_stream1 =
2022 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); 2052 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
2053 session, url1, MEDIUM, BoundNetLog());
2023 ASSERT_TRUE(spdy_stream1.get() != NULL); 2054 ASSERT_TRUE(spdy_stream1.get() != NULL);
2024 EXPECT_EQ(0u, spdy_stream1->stream_id()); 2055 EXPECT_EQ(0u, spdy_stream1->stream_id());
2025 test::StreamDelegateDoNothing delegate1(spdy_stream1); 2056 test::StreamDelegateDoNothing delegate1(spdy_stream1);
2026 spdy_stream1->SetDelegate(&delegate1); 2057 spdy_stream1->SetDelegate(&delegate1);
2027 2058
2028 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 2059 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
2029 (*headers)["method"] = "GET"; 2060 (*headers)["method"] = "GET";
2030 (*headers)["scheme"] = url1.scheme(); 2061 (*headers)["scheme"] = url1.scheme();
2031 (*headers)["host"] = url1.host(); 2062 (*headers)["host"] = url1.host();
2032 (*headers)["url"] = url1.path(); 2063 (*headers)["url"] = url1.path();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 2121
2091 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 2122 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
2092 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 2123 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
2093 2124
2094 CreateDeterministicNetworkSession(); 2125 CreateDeterministicNetworkSession();
2095 2126
2096 scoped_refptr<SpdySession> session = CreateInitializedSession(); 2127 scoped_refptr<SpdySession> session = CreateInitializedSession();
2097 2128
2098 GURL url1("http://www.google.com"); 2129 GURL url1("http://www.google.com");
2099 base::WeakPtr<SpdyStream> spdy_stream1 = 2130 base::WeakPtr<SpdyStream> spdy_stream1 =
2100 CreateStreamSynchronously(session, url1, MEDIUM, BoundNetLog()); 2131 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
2132 session, url1, MEDIUM, BoundNetLog());
2101 session = NULL; 2133 session = NULL;
2102 ASSERT_TRUE(spdy_stream1.get() != NULL); 2134 ASSERT_TRUE(spdy_stream1.get() != NULL);
2103 EXPECT_EQ(0u, spdy_stream1->stream_id()); 2135 EXPECT_EQ(0u, spdy_stream1->stream_id());
2104 2136
2105 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 2137 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
2106 (*headers)["method"] = "GET"; 2138 (*headers)["method"] = "GET";
2107 (*headers)["scheme"] = url1.scheme(); 2139 (*headers)["scheme"] = url1.scheme();
2108 (*headers)["host"] = url1.host(); 2140 (*headers)["host"] = url1.host();
2109 (*headers)["url"] = url1.path(); 2141 (*headers)["url"] = url1.path();
2110 (*headers)["version"] = "HTTP/1.1"; 2142 (*headers)["version"] = "HTTP/1.1";
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 EXPECT_EQ( 2344 EXPECT_EQ(
2313 OK, 2345 OK,
2314 InitializeSession(http_session_.get(), session1.get(), 2346 InitializeSession(http_session_.get(), session1.get(),
2315 key1.host_port_pair())); 2347 key1.host_port_pair()));
2316 EXPECT_FALSE(pool->IsStalled()); 2348 EXPECT_FALSE(pool->IsStalled());
2317 2349
2318 // Create a stream using the session, and send a request. 2350 // Create a stream using the session, and send a request.
2319 2351
2320 TestCompletionCallback callback1; 2352 TestCompletionCallback callback1;
2321 base::WeakPtr<SpdyStream> spdy_stream1 = 2353 base::WeakPtr<SpdyStream> spdy_stream1 =
2322 CreateStreamSynchronously(session1, url1, DEFAULT_PRIORITY, 2354 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
2355 session1, url1, DEFAULT_PRIORITY,
2323 BoundNetLog()); 2356 BoundNetLog());
2324 ASSERT_TRUE(spdy_stream1.get()); 2357 ASSERT_TRUE(spdy_stream1.get());
2325 2358
2326 scoped_ptr<SpdyHeaderBlock> headers( 2359 scoped_ptr<SpdyHeaderBlock> headers(
2327 spdy_util_.ConstructGetHeaderBlock(url1.spec())); 2360 spdy_util_.ConstructGetHeaderBlock(url1.spec()));
2328 spdy_stream1->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND); 2361 spdy_stream1->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND);
2329 EXPECT_TRUE(spdy_stream1->HasUrl()); 2362 EXPECT_TRUE(spdy_stream1->HasUrl());
2330 base::MessageLoop::current()->RunUntilIdle(); 2363 base::MessageLoop::current()->RunUntilIdle();
2331 2364
2332 // Release the session, so holding onto a pointer here does not affect 2365 // Release the session, so holding onto a pointer here does not affect
(...skipping 23 matching lines...) Expand all
2356 // Cancelling the request should still not release the session's socket, 2389 // Cancelling the request should still not release the session's socket,
2357 // since the session is still kept alive by the SpdySessionPool. 2390 // since the session is still kept alive by the SpdySessionPool.
2358 ASSERT_TRUE(spdy_stream1.get()); 2391 ASSERT_TRUE(spdy_stream1.get());
2359 spdy_stream1->Cancel(); 2392 spdy_stream1->Cancel();
2360 base::RunLoop().RunUntilIdle(); 2393 base::RunLoop().RunUntilIdle();
2361 EXPECT_TRUE(pool->IsStalled()); 2394 EXPECT_TRUE(pool->IsStalled());
2362 EXPECT_FALSE(callback2.have_result()); 2395 EXPECT_FALSE(callback2.have_result());
2363 } 2396 }
2364 2397
2365 } // namespace net 2398 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698