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/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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 96 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
97 } | 97 } |
98 }; | 98 }; |
99 | 99 |
100 // Subclass of QuicHttpStream that closes itself when the first piece of data | 100 // Subclass of QuicHttpStream that closes itself when the first piece of data |
101 // is received. | 101 // is received. |
102 class AutoClosingStream : public QuicHttpStream { | 102 class AutoClosingStream : public QuicHttpStream { |
103 public: | 103 public: |
104 explicit AutoClosingStream( | 104 explicit AutoClosingStream( |
105 const base::WeakPtr<QuicChromiumClientSession>& session, | 105 const base::WeakPtr<QuicChromiumClientSession>& session, |
106 HttpServerProperties* http_server_properties) | 106 HttpServerProperties* http_server_properties, |
107 : QuicHttpStream(session, http_server_properties) {} | 107 bool mark_quic_broken_when_network_suspected) |
108 : QuicHttpStream(session, | |
109 http_server_properties, | |
110 mark_quic_broken_when_network_suspected) {} | |
108 | 111 |
109 void OnHeadersAvailable(const SpdyHeaderBlock& headers, | 112 void OnHeadersAvailable(const SpdyHeaderBlock& headers, |
110 size_t frame_len) override { | 113 size_t frame_len) override { |
111 Close(false); | 114 Close(false); |
112 } | 115 } |
113 | 116 |
114 void OnDataAvailable() override { Close(false); } | 117 void OnDataAvailable() override { Close(false); } |
115 }; | 118 }; |
116 | 119 |
117 // UploadDataStream that always returns errors on data read. | 120 // UploadDataStream that always returns errors on data read. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 PacketToWrite(IoMode mode, int rv) : mode(mode), packet(nullptr), rv(rv) {} | 203 PacketToWrite(IoMode mode, int rv) : mode(mode), packet(nullptr), rv(rv) {} |
201 IoMode mode; | 204 IoMode mode; |
202 QuicReceivedPacket* packet; | 205 QuicReceivedPacket* packet; |
203 int rv; | 206 int rv; |
204 }; | 207 }; |
205 | 208 |
206 QuicHttpStreamTest() | 209 QuicHttpStreamTest() |
207 : use_closing_stream_(false), | 210 : use_closing_stream_(false), |
208 crypto_config_(crypto_test_utils::ProofVerifierForTesting()), | 211 crypto_config_(crypto_test_utils::ProofVerifierForTesting()), |
209 read_buffer_(new IOBufferWithSize(4096)), | 212 read_buffer_(new IOBufferWithSize(4096)), |
213 mark_quic_broken_when_network_suspected_(false), | |
210 promise_id_(kServerDataStreamId1), | 214 promise_id_(kServerDataStreamId1), |
211 stream_id_(kClientDataStreamId1), | 215 stream_id_(kClientDataStreamId1), |
212 connection_id_(2), | 216 connection_id_(2), |
213 client_maker_(GetParam(), | 217 client_maker_(GetParam(), |
214 connection_id_, | 218 connection_id_, |
215 &clock_, | 219 &clock_, |
216 kDefaultServerHostName, | 220 kDefaultServerHostName, |
217 Perspective::IS_CLIENT), | 221 Perspective::IS_CLIENT), |
218 server_maker_(GetParam(), | 222 server_maker_(GetParam(), |
219 connection_id_, | 223 connection_id_, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), | 329 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), |
326 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, | 330 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, |
327 "CONNECTION_UNKNOWN", dns_start, dns_end, &push_promise_index_, nullptr, | 331 "CONNECTION_UNKNOWN", dns_start, dns_end, &push_promise_index_, nullptr, |
328 base::ThreadTaskRunnerHandle::Get().get(), | 332 base::ThreadTaskRunnerHandle::Get().get(), |
329 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log())); | 333 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log())); |
330 session_->Initialize(); | 334 session_->Initialize(); |
331 TestCompletionCallback callback; | 335 TestCompletionCallback callback; |
332 session_->CryptoConnect(callback.callback()); | 336 session_->CryptoConnect(callback.callback()); |
333 EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); | 337 EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); |
334 stream_.reset(use_closing_stream_ | 338 stream_.reset(use_closing_stream_ |
335 ? new AutoClosingStream(session_->GetWeakPtr(), | 339 ? new AutoClosingStream( |
336 &http_server_properties_) | 340 session_->GetWeakPtr(), &http_server_properties_, |
337 : new QuicHttpStream(session_->GetWeakPtr(), | 341 mark_quic_broken_when_network_suspected_) |
338 &http_server_properties_)); | 342 : new QuicHttpStream( |
343 session_->GetWeakPtr(), &http_server_properties_, | |
344 mark_quic_broken_when_network_suspected_)); | |
339 | 345 |
340 promised_stream_.reset(use_closing_stream_ | 346 promised_stream_.reset( |
341 ? new AutoClosingStream(session_->GetWeakPtr(), | 347 use_closing_stream_ |
342 &http_server_properties_) | 348 ? new AutoClosingStream(session_->GetWeakPtr(), |
343 : new QuicHttpStream(session_->GetWeakPtr(), | 349 &http_server_properties_, |
344 &http_server_properties_)); | 350 mark_quic_broken_when_network_suspected_) |
351 : new QuicHttpStream(session_->GetWeakPtr(), | |
352 &http_server_properties_, | |
353 mark_quic_broken_when_network_suspected_)); | |
345 | 354 |
346 push_promise_[":path"] = "/bar"; | 355 push_promise_[":path"] = "/bar"; |
347 push_promise_[":authority"] = "www.example.org"; | 356 push_promise_[":authority"] = "www.example.org"; |
348 push_promise_[":version"] = "HTTP/1.1"; | 357 push_promise_[":version"] = "HTTP/1.1"; |
349 push_promise_[":method"] = "GET"; | 358 push_promise_[":method"] = "GET"; |
350 push_promise_[":scheme"] = "https"; | 359 push_promise_[":scheme"] = "https"; |
351 | 360 |
352 promised_response_[":status"] = "200 OK"; | 361 promised_response_[":status"] = "200 OK"; |
353 promised_response_[":version"] = "HTTP/1.1"; | 362 promised_response_[":version"] = "HTTP/1.1"; |
354 promised_response_["content-type"] = "text/plain"; | 363 promised_response_["content-type"] = "text/plain"; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 TestCompletionCallback callback_; | 586 TestCompletionCallback callback_; |
578 HttpRequestInfo request_; | 587 HttpRequestInfo request_; |
579 HttpRequestHeaders headers_; | 588 HttpRequestHeaders headers_; |
580 HttpResponseInfo response_; | 589 HttpResponseInfo response_; |
581 scoped_refptr<IOBufferWithSize> read_buffer_; | 590 scoped_refptr<IOBufferWithSize> read_buffer_; |
582 SpdyHeaderBlock request_headers_; | 591 SpdyHeaderBlock request_headers_; |
583 SpdyHeaderBlock response_headers_; | 592 SpdyHeaderBlock response_headers_; |
584 string request_data_; | 593 string request_data_; |
585 string response_data_; | 594 string response_data_; |
586 QuicClientPushPromiseIndex push_promise_index_; | 595 QuicClientPushPromiseIndex push_promise_index_; |
596 bool mark_quic_broken_when_network_suspected_; | |
Bence
2017/04/03 19:02:59
This member is always false, so consider a file-sc
Ryan Hamilton
2017/04/05 19:26:20
Done.
Bence
2017/04/05 23:49:46
Sorry, I was rather thinking of setting kMarkQuicB
Ryan Hamilton
2017/04/08 00:07:23
I see. As it happens, I ended up reverting the cha
| |
587 | 597 |
588 // For server push testing | 598 // For server push testing |
589 std::unique_ptr<QuicHttpStream> promised_stream_; | 599 std::unique_ptr<QuicHttpStream> promised_stream_; |
590 SpdyHeaderBlock push_promise_; | 600 SpdyHeaderBlock push_promise_; |
591 SpdyHeaderBlock promised_response_; | 601 SpdyHeaderBlock promised_response_; |
592 const QuicStreamId promise_id_; | 602 const QuicStreamId promise_id_; |
593 string promise_url_; | 603 string promise_url_; |
594 string serialized_push_promise_; | 604 string serialized_push_promise_; |
595 const QuicStreamId stream_id_; | 605 const QuicStreamId stream_id_; |
596 | 606 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 request_.method = "GET"; | 728 request_.method = "GET"; |
719 request_.url = GURL("http://www.example.org/"); | 729 request_.url = GURL("http://www.example.org/"); |
720 // Start first request. | 730 // Start first request. |
721 EXPECT_EQ(OK, | 731 EXPECT_EQ(OK, |
722 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 732 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
723 net_log_.bound(), callback_.callback())); | 733 net_log_.bound(), callback_.callback())); |
724 EXPECT_EQ(OK, | 734 EXPECT_EQ(OK, |
725 stream_->SendRequest(headers_, &response_, callback_.callback())); | 735 stream_->SendRequest(headers_, &response_, callback_.callback())); |
726 | 736 |
727 // Start a second request. | 737 // Start a second request. |
728 QuicHttpStream stream2(session_->GetWeakPtr(), &http_server_properties_); | 738 QuicHttpStream stream2(session_->GetWeakPtr(), &http_server_properties_, |
739 mark_quic_broken_when_network_suspected_); | |
729 TestCompletionCallback callback2; | 740 TestCompletionCallback callback2; |
730 EXPECT_EQ(OK, | 741 EXPECT_EQ(OK, |
731 stream2.InitializeStream(&request_, DEFAULT_PRIORITY, | 742 stream2.InitializeStream(&request_, DEFAULT_PRIORITY, |
732 net_log_.bound(), callback2.callback())); | 743 net_log_.bound(), callback2.callback())); |
733 EXPECT_EQ(OK, | 744 EXPECT_EQ(OK, |
734 stream2.SendRequest(headers_, &response_, callback2.callback())); | 745 stream2.SendRequest(headers_, &response_, callback2.callback())); |
735 | 746 |
736 // Ack both requests. | 747 // Ack both requests. |
737 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 748 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
738 | 749 |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2169 EXPECT_TRUE(AtEof()); | 2180 EXPECT_TRUE(AtEof()); |
2170 | 2181 |
2171 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. | 2182 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. |
2172 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 2183 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
2173 stream_->GetTotalSentBytes()); | 2184 stream_->GetTotalSentBytes()); |
2174 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 2185 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
2175 } | 2186 } |
2176 | 2187 |
2177 } // namespace test | 2188 } // namespace test |
2178 } // namespace net | 2189 } // namespace net |
OLD | NEW |