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

Side by Side Diff: net/quic/chromium/quic_http_stream_test.cc

Issue 2908243002: Remove QuicChromiumClientStream::Delegate in favor of async methods. (Closed)
Patch Set: No expect_trailers_ Created 3 years, 6 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
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/quic/chromium/quic_http_stream.h" 5 #include "net/quic/chromium/quic_http_stream.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 ProcessPacket(ConstructServerAckPacket(1, 0, 0, 0)); 1396 ProcessPacket(ConstructServerAckPacket(1, 0, 0, 0));
1397 EXPECT_THAT(stream_->ReadResponseHeaders( 1397 EXPECT_THAT(stream_->ReadResponseHeaders(
1398 base::Bind(&QuicHttpStreamTest::CloseStream, 1398 base::Bind(&QuicHttpStreamTest::CloseStream,
1399 base::Unretained(this), stream_.get())), 1399 base::Unretained(this), stream_.get())),
1400 IsError(ERR_IO_PENDING)); 1400 IsError(ERR_IO_PENDING));
1401 1401
1402 // Send the response with a body. 1402 // Send the response with a body.
1403 SetResponse("404 OK", "hello world!"); 1403 SetResponse("404 OK", "hello world!");
1404 // In the course of processing this packet, the QuicHttpStream close itself. 1404 // In the course of processing this packet, the QuicHttpStream close itself.
1405 size_t response_size = 0; 1405 size_t response_size = 0;
1406 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, &response_size)); 1406 ProcessPacket(ConstructResponseHeadersPacket(2, !kFin, &response_size));
1407 1407
1408 base::RunLoop().RunUntilIdle(); 1408 base::RunLoop().RunUntilIdle();
1409 1409
1410 EXPECT_TRUE(AtEof()); 1410 EXPECT_TRUE(AtEof());
1411 1411
1412 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the 1412 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the
1413 // headers and payload. 1413 // headers and payload.
1414 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), 1414 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length),
1415 stream_->GetTotalSentBytes()); 1415 stream_->GetTotalSentBytes());
1416 // The stream was closed after receiving the headers. 1416 // The stream was closed after receiving the headers.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 EXPECT_TRUE(AtEof()); 1462 EXPECT_TRUE(AtEof());
1463 1463
1464 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the 1464 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the
1465 // headers and payload. 1465 // headers and payload.
1466 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), 1466 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length),
1467 stream_->GetTotalSentBytes()); 1467 stream_->GetTotalSentBytes());
1468 EXPECT_EQ(static_cast<int64_t>(response_size), 1468 EXPECT_EQ(static_cast<int64_t>(response_size),
1469 stream_->GetTotalReceivedBytes()); 1469 stream_->GetTotalReceivedBytes());
1470 } 1470 }
1471 1471
1472 // Regression test for http://crbug.com/294870
1473 TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) {
1474 SetRequest("GET", "/", MEDIUM);
1475 QuicStreamOffset header_stream_offset = 0;
1476 AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
1477 AddWrite(ConstructClientRstStreamPacket(2));
1478
1479 Initialize();
1480
1481 request_.method = "GET";
1482 request_.url = GURL("https://www.example.org/");
1483
1484 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(),
1485 callback_.callback()));
1486
1487 // Check that priority is highest.
1488 QuicChromiumClientStream::Handle* reliable_stream =
1489 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get());
1490 DCHECK(reliable_stream);
1491 QuicChromiumClientStream::Delegate* delegate = reliable_stream->GetDelegate();
1492 DCHECK(delegate);
1493 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority());
1494
1495 // Set Delegate to nullptr and make sure Priority returns highest
1496 // priority.
1497 reliable_stream->ClearDelegate();
1498 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority());
1499
1500 EXPECT_EQ(0, stream_->GetTotalSentBytes());
1501 EXPECT_EQ(0, stream_->GetTotalReceivedBytes());
1502 }
1503
1504 TEST_P(QuicHttpStreamTest, SessionClosedDuringDoLoop) { 1472 TEST_P(QuicHttpStreamTest, SessionClosedDuringDoLoop) {
1505 SetRequest("POST", "/", DEFAULT_PRIORITY); 1473 SetRequest("POST", "/", DEFAULT_PRIORITY);
1506 size_t spdy_request_headers_frame_length; 1474 size_t spdy_request_headers_frame_length;
1507 QuicStreamOffset header_stream_offset = 0; 1475 QuicStreamOffset header_stream_offset = 0;
1508 AddWrite(ConstructInitialSettingsPacket(&header_stream_offset)); 1476 AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
1509 AddWrite(InnerConstructRequestHeadersPacket( 1477 AddWrite(InnerConstructRequestHeadersPacket(
1510 2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin, 1478 2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
1511 DEFAULT_PRIORITY, &spdy_request_headers_frame_length, 1479 DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
1512 &header_stream_offset)); 1480 &header_stream_offset));
1513 AddWrite( 1481 AddWrite(
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 EXPECT_TRUE(AtEof()); 2111 EXPECT_TRUE(AtEof());
2144 2112
2145 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. 2113 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers.
2146 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), 2114 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length),
2147 stream_->GetTotalSentBytes()); 2115 stream_->GetTotalSentBytes());
2148 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); 2116 EXPECT_EQ(0, stream_->GetTotalReceivedBytes());
2149 } 2117 }
2150 2118
2151 } // namespace test 2119 } // namespace test
2152 } // namespace net 2120 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.cc ('k') | net/quic/chromium/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698