| OLD | NEW |
| 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/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 base::StringPiece data) { | 257 base::StringPiece data) { |
| 258 return maker_.MakeDataPacket(packet_number, stream_id_, | 258 return maker_.MakeDataPacket(packet_number, stream_id_, |
| 259 should_include_version, fin, offset, data); | 259 should_include_version, fin, offset, data); |
| 260 } | 260 } |
| 261 | 261 |
| 262 scoped_ptr<QuicEncryptedPacket> ConstructRequestHeadersPacket( | 262 scoped_ptr<QuicEncryptedPacket> ConstructRequestHeadersPacket( |
| 263 QuicPacketNumber packet_number, | 263 QuicPacketNumber packet_number, |
| 264 bool fin, | 264 bool fin, |
| 265 RequestPriority request_priority, | 265 RequestPriority request_priority, |
| 266 size_t* spdy_headers_frame_length) { | 266 size_t* spdy_headers_frame_length) { |
| 267 QuicPriority priority = | 267 SpdyPriority priority = |
| 268 ConvertRequestPriorityToQuicPriority(request_priority); | 268 ConvertRequestPriorityToQuicPriority(request_priority); |
| 269 return maker_.MakeRequestHeadersPacket( | 269 return maker_.MakeRequestHeadersPacket( |
| 270 packet_number, stream_id_, kIncludeVersion, fin, priority, | 270 packet_number, stream_id_, kIncludeVersion, fin, priority, |
| 271 request_headers_, spdy_headers_frame_length); | 271 request_headers_, spdy_headers_frame_length); |
| 272 } | 272 } |
| 273 | 273 |
| 274 scoped_ptr<QuicEncryptedPacket> ConstructResponseHeadersPacket( | 274 scoped_ptr<QuicEncryptedPacket> ConstructResponseHeadersPacket( |
| 275 QuicPacketNumber packet_number, | 275 QuicPacketNumber packet_number, |
| 276 bool fin, | 276 bool fin, |
| 277 size_t* spdy_headers_frame_length) { | 277 size_t* spdy_headers_frame_length) { |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 request_.method = "GET"; | 815 request_.method = "GET"; |
| 816 request_.url = GURL("http://www.google.com/"); | 816 request_.url = GURL("http://www.google.com/"); |
| 817 | 817 |
| 818 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, | 818 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, |
| 819 net_log_, callback_.callback())); | 819 net_log_, callback_.callback())); |
| 820 | 820 |
| 821 // Check that priority is highest. | 821 // Check that priority is highest. |
| 822 QuicReliableClientStream* reliable_stream = | 822 QuicReliableClientStream* reliable_stream = |
| 823 QuicHttpStreamPeer::GetQuicReliableClientStream(stream_.get()); | 823 QuicHttpStreamPeer::GetQuicReliableClientStream(stream_.get()); |
| 824 DCHECK(reliable_stream); | 824 DCHECK(reliable_stream); |
| 825 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 825 DCHECK_EQ(kHighestPriority, reliable_stream->Priority()); |
| 826 reliable_stream->EffectivePriority()); | |
| 827 | 826 |
| 828 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 827 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
| 829 callback_.callback())); | 828 callback_.callback())); |
| 830 | 829 |
| 831 // Check that priority has now dropped back to MEDIUM. | 830 // Check that priority has now dropped back to MEDIUM. |
| 832 DCHECK_EQ(MEDIUM, ConvertQuicPriorityToRequestPriority( | 831 DCHECK_EQ(MEDIUM, ConvertQuicPriorityToRequestPriority( |
| 833 reliable_stream->EffectivePriority())); | 832 reliable_stream->Priority())); |
| 834 | 833 |
| 835 // Ack the request. | 834 // Ack the request. |
| 836 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 835 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
| 837 EXPECT_EQ(ERR_IO_PENDING, | 836 EXPECT_EQ(ERR_IO_PENDING, |
| 838 stream_->ReadResponseHeaders(callback_.callback())); | 837 stream_->ReadResponseHeaders(callback_.callback())); |
| 839 | 838 |
| 840 // Send the response with a body. | 839 // Send the response with a body. |
| 841 SetResponse("404 OK", "hello world!"); | 840 SetResponse("404 OK", "hello world!"); |
| 842 // In the course of processing this packet, the QuicHttpStream close itself. | 841 // In the course of processing this packet, the QuicHttpStream close itself. |
| 843 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, nullptr)); | 842 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, nullptr)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 868 | 867 |
| 869 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, | 868 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, |
| 870 net_log_, callback_.callback())); | 869 net_log_, callback_.callback())); |
| 871 | 870 |
| 872 // Check that priority is highest. | 871 // Check that priority is highest. |
| 873 QuicReliableClientStream* reliable_stream = | 872 QuicReliableClientStream* reliable_stream = |
| 874 QuicHttpStreamPeer::GetQuicReliableClientStream(stream_.get()); | 873 QuicHttpStreamPeer::GetQuicReliableClientStream(stream_.get()); |
| 875 DCHECK(reliable_stream); | 874 DCHECK(reliable_stream); |
| 876 QuicReliableClientStream::Delegate* delegate = reliable_stream->GetDelegate(); | 875 QuicReliableClientStream::Delegate* delegate = reliable_stream->GetDelegate(); |
| 877 DCHECK(delegate); | 876 DCHECK(delegate); |
| 878 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 877 DCHECK_EQ(kHighestPriority, reliable_stream->Priority()); |
| 879 reliable_stream->EffectivePriority()); | |
| 880 | 878 |
| 881 // Set Delegate to nullptr and make sure EffectivePriority returns highest | 879 // Set Delegate to nullptr and make sure Priority returns highest |
| 882 // priority. | 880 // priority. |
| 883 reliable_stream->SetDelegate(nullptr); | 881 reliable_stream->SetDelegate(nullptr); |
| 884 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 882 DCHECK_EQ(kHighestPriority, reliable_stream->Priority()); |
| 885 reliable_stream->EffectivePriority()); | |
| 886 reliable_stream->SetDelegate(delegate); | 883 reliable_stream->SetDelegate(delegate); |
| 887 | 884 |
| 888 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | 885 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 889 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 886 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 890 } | 887 } |
| 891 | 888 |
| 892 } // namespace test | 889 } // namespace test |
| 893 } // namespace net | 890 } // namespace net |
| OLD | NEW |