| 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 <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
| 23 #include "net/http/transport_security_state.h" | 23 #include "net/http/transport_security_state.h" |
| 24 #include "net/log/test_net_log.h" | 24 #include "net/log/test_net_log.h" |
| 25 #include "net/log/test_net_log_util.h" | 25 #include "net/log/test_net_log_util.h" |
| 26 #include "net/quic/congestion_control/send_algorithm_interface.h" | 26 #include "net/quic/congestion_control/send_algorithm_interface.h" |
| 27 #include "net/quic/crypto/crypto_protocol.h" | 27 #include "net/quic/crypto/crypto_protocol.h" |
| 28 #include "net/quic/crypto/proof_verifier_chromium.h" | 28 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 29 #include "net/quic/crypto/quic_decrypter.h" | 29 #include "net/quic/crypto/quic_decrypter.h" |
| 30 #include "net/quic/crypto/quic_encrypter.h" | 30 #include "net/quic/crypto/quic_encrypter.h" |
| 31 #include "net/quic/crypto/quic_server_info.h" | 31 #include "net/quic/crypto/quic_server_info.h" |
| 32 #include "net/quic/quic_chromium_alarm_factory.h" |
| 32 #include "net/quic/quic_chromium_client_session.h" | 33 #include "net/quic/quic_chromium_client_session.h" |
| 33 #include "net/quic/quic_chromium_client_stream.h" | 34 #include "net/quic/quic_chromium_client_stream.h" |
| 34 #include "net/quic/quic_chromium_connection_helper.h" | 35 #include "net/quic/quic_chromium_connection_helper.h" |
| 35 #include "net/quic/quic_chromium_packet_reader.h" | 36 #include "net/quic/quic_chromium_packet_reader.h" |
| 36 #include "net/quic/quic_chromium_packet_writer.h" | 37 #include "net/quic/quic_chromium_packet_writer.h" |
| 37 #include "net/quic/quic_connection.h" | 38 #include "net/quic/quic_connection.h" |
| 38 #include "net/quic/quic_http_utils.h" | 39 #include "net/quic/quic_http_utils.h" |
| 39 #include "net/quic/quic_write_blocked_list.h" | 40 #include "net/quic/quic_write_blocked_list.h" |
| 40 #include "net/quic/spdy_utils.h" | 41 #include "net/quic/spdy_utils.h" |
| 41 #include "net/quic/test_tools/crypto_test_utils.h" | 42 #include "net/quic/test_tools/crypto_test_utils.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 const char kUploadData[] = "Really nifty data!"; | 68 const char kUploadData[] = "Really nifty data!"; |
| 68 const char kDefaultServerHostName[] = "www.example.org"; | 69 const char kDefaultServerHostName[] = "www.example.org"; |
| 69 const uint16_t kDefaultServerPort = 80; | 70 const uint16_t kDefaultServerPort = 80; |
| 70 | 71 |
| 71 class TestQuicConnection : public QuicConnection { | 72 class TestQuicConnection : public QuicConnection { |
| 72 public: | 73 public: |
| 73 TestQuicConnection(const QuicVersionVector& versions, | 74 TestQuicConnection(const QuicVersionVector& versions, |
| 74 QuicConnectionId connection_id, | 75 QuicConnectionId connection_id, |
| 75 IPEndPoint address, | 76 IPEndPoint address, |
| 76 QuicChromiumConnectionHelper* helper, | 77 QuicChromiumConnectionHelper* helper, |
| 78 QuicChromiumAlarmFactory* factory, |
| 77 QuicPacketWriter* writer) | 79 QuicPacketWriter* writer) |
| 78 : QuicConnection(connection_id, | 80 : QuicConnection(connection_id, |
| 79 address, | 81 address, |
| 80 helper, | 82 helper, |
| 83 factory, |
| 81 writer, | 84 writer, |
| 82 true /* owns_writer */, | 85 true /* owns_writer */, |
| 83 Perspective::IS_CLIENT, | 86 Perspective::IS_CLIENT, |
| 84 versions) {} | 87 versions) {} |
| 85 | 88 |
| 86 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { | 89 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { |
| 87 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 90 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
| 88 } | 91 } |
| 89 }; | 92 }; |
| 90 | 93 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 .WillRepeatedly(Return(QuicTime::Delta::Zero())); | 214 .WillRepeatedly(Return(QuicTime::Delta::Zero())); |
| 212 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) | 215 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
| 213 .WillRepeatedly(Return(kMaxPacketSize)); | 216 .WillRepeatedly(Return(kMaxPacketSize)); |
| 214 EXPECT_CALL(*send_algorithm_, PacingRate()) | 217 EXPECT_CALL(*send_algorithm_, PacingRate()) |
| 215 .WillRepeatedly(Return(QuicBandwidth::Zero())); | 218 .WillRepeatedly(Return(QuicBandwidth::Zero())); |
| 216 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) | 219 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) |
| 217 .WillRepeatedly(Return(QuicTime::Delta::Zero())); | 220 .WillRepeatedly(Return(QuicTime::Delta::Zero())); |
| 218 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) | 221 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) |
| 219 .WillRepeatedly(Return(QuicBandwidth::Zero())); | 222 .WillRepeatedly(Return(QuicBandwidth::Zero())); |
| 220 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber()); | 223 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber()); |
| 221 helper_.reset(new QuicChromiumConnectionHelper(runner_.get(), &clock_, | 224 helper_.reset( |
| 222 &random_generator_)); | 225 new QuicChromiumConnectionHelper(&clock_, &random_generator_)); |
| 223 connection_ = new TestQuicConnection( | 226 alarm_factory_.reset(new QuicChromiumAlarmFactory(runner_.get(), &clock_)); |
| 224 SupportedVersions(GetParam()), connection_id_, peer_addr_, | 227 connection_ = |
| 225 helper_.get(), new QuicChromiumPacketWriter(socket.get())); | 228 new TestQuicConnection(SupportedVersions(GetParam()), connection_id_, |
| 229 peer_addr_, helper_.get(), alarm_factory_.get(), |
| 230 new QuicChromiumPacketWriter(socket.get())); |
| 226 connection_->set_visitor(&visitor_); | 231 connection_->set_visitor(&visitor_); |
| 227 connection_->SetSendAlgorithm(send_algorithm_); | 232 connection_->SetSendAlgorithm(send_algorithm_); |
| 228 | 233 |
| 229 // Load a certificate that is valid for *.example.org | 234 // Load a certificate that is valid for *.example.org |
| 230 scoped_refptr<X509Certificate> test_cert( | 235 scoped_refptr<X509Certificate> test_cert( |
| 231 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem")); | 236 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem")); |
| 232 EXPECT_TRUE(test_cert.get()); | 237 EXPECT_TRUE(test_cert.get()); |
| 233 | 238 |
| 234 verify_details_.cert_verify_result.verified_cert = test_cert; | 239 verify_details_.cert_verify_result.verified_cert = test_cert; |
| 235 verify_details_.cert_verify_result.is_issued_by_known_root = true; | 240 verify_details_.cert_verify_result.is_issued_by_known_root = true; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 427 } |
| 423 | 428 |
| 424 BoundTestNetLog net_log_; | 429 BoundTestNetLog net_log_; |
| 425 bool use_closing_stream_; | 430 bool use_closing_stream_; |
| 426 MockSendAlgorithm* send_algorithm_; | 431 MockSendAlgorithm* send_algorithm_; |
| 427 scoped_refptr<TestTaskRunner> runner_; | 432 scoped_refptr<TestTaskRunner> runner_; |
| 428 std::unique_ptr<MockWrite[]> mock_writes_; | 433 std::unique_ptr<MockWrite[]> mock_writes_; |
| 429 MockClock clock_; | 434 MockClock clock_; |
| 430 TestQuicConnection* connection_; | 435 TestQuicConnection* connection_; |
| 431 std::unique_ptr<QuicChromiumConnectionHelper> helper_; | 436 std::unique_ptr<QuicChromiumConnectionHelper> helper_; |
| 437 std::unique_ptr<QuicChromiumAlarmFactory> alarm_factory_; |
| 432 testing::StrictMock<MockConnectionVisitor> visitor_; | 438 testing::StrictMock<MockConnectionVisitor> visitor_; |
| 433 std::unique_ptr<QuicHttpStream> stream_; | 439 std::unique_ptr<QuicHttpStream> stream_; |
| 434 TransportSecurityState transport_security_state_; | 440 TransportSecurityState transport_security_state_; |
| 435 std::unique_ptr<QuicChromiumClientSession> session_; | 441 std::unique_ptr<QuicChromiumClientSession> session_; |
| 436 QuicCryptoClientConfig crypto_config_; | 442 QuicCryptoClientConfig crypto_config_; |
| 437 TestCompletionCallback callback_; | 443 TestCompletionCallback callback_; |
| 438 HttpRequestInfo request_; | 444 HttpRequestInfo request_; |
| 439 HttpRequestHeaders headers_; | 445 HttpRequestHeaders headers_; |
| 440 HttpResponseInfo response_; | 446 HttpResponseInfo response_; |
| 441 scoped_refptr<IOBufferWithSize> read_buffer_; | 447 scoped_refptr<IOBufferWithSize> read_buffer_; |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | 1684 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 1679 // headers and payload. | 1685 // headers and payload. |
| 1680 EXPECT_EQ(static_cast<int64_t>(spdy_request_header_frame_length), | 1686 EXPECT_EQ(static_cast<int64_t>(spdy_request_header_frame_length), |
| 1681 promised_stream_->GetTotalSentBytes()); | 1687 promised_stream_->GetTotalSentBytes()); |
| 1682 EXPECT_EQ(static_cast<int64_t>(spdy_response_header_frame_length), | 1688 EXPECT_EQ(static_cast<int64_t>(spdy_response_header_frame_length), |
| 1683 promised_stream_->GetTotalReceivedBytes()); | 1689 promised_stream_->GetTotalReceivedBytes()); |
| 1684 } | 1690 } |
| 1685 | 1691 |
| 1686 } // namespace test | 1692 } // namespace test |
| 1687 } // namespace net | 1693 } // namespace net |
| OLD | NEW |