| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/quic/quic_simple_server_session.h" | 5 #include "net/tools/quic/quic_simple_server_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 12 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
| 13 #include "net/quic/core/crypto/quic_random.h" | 13 #include "net/quic/core/crypto/quic_random.h" |
| 14 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 14 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
| 15 #include "net/quic/core/quic_connection.h" | 15 #include "net/quic/core/quic_connection.h" |
| 16 #include "net/quic/core/quic_crypto_server_stream.h" | 16 #include "net/quic/core/quic_crypto_server_stream.h" |
| 17 #include "net/quic/core/quic_utils.h" | 17 #include "net/quic/core/quic_utils.h" |
| 18 #include "net/quic/platform/api/quic_socket_address.h" | 18 #include "net/quic/platform/api/quic_socket_address.h" |
| 19 #include "net/quic/platform/api/quic_text_utils.h" |
| 19 #include "net/quic/test_tools/crypto_test_utils.h" | 20 #include "net/quic/test_tools/crypto_test_utils.h" |
| 20 #include "net/quic/test_tools/quic_config_peer.h" | 21 #include "net/quic/test_tools/quic_config_peer.h" |
| 21 #include "net/quic/test_tools/quic_connection_peer.h" | 22 #include "net/quic/test_tools/quic_connection_peer.h" |
| 22 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 23 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 23 #include "net/quic/test_tools/quic_session_peer.h" | 24 #include "net/quic/test_tools/quic_session_peer.h" |
| 24 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 25 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| 25 #include "net/quic/test_tools/quic_spdy_stream_peer.h" | 26 #include "net/quic/test_tools/quic_spdy_stream_peer.h" |
| 26 #include "net/quic/test_tools/quic_stream_peer.h" | 27 #include "net/quic/test_tools/quic_stream_peer.h" |
| 27 #include "net/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" | 28 #include "net/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" |
| 28 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); | 456 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); |
| 456 | 457 |
| 457 string request_url = "mail.google.com/"; | 458 string request_url = "mail.google.com/"; |
| 458 SpdyHeaderBlock request_headers; | 459 SpdyHeaderBlock request_headers; |
| 459 string resource_host = "www.google.com"; | 460 string resource_host = "www.google.com"; |
| 460 string partial_push_resource_path = "/server_push_src"; | 461 string partial_push_resource_path = "/server_push_src"; |
| 461 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources; | 462 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources; |
| 462 string scheme = "http"; | 463 string scheme = "http"; |
| 463 for (unsigned int i = 1; i <= num_resources; ++i) { | 464 for (unsigned int i = 1; i <= num_resources; ++i) { |
| 464 QuicStreamId stream_id = i * 2; | 465 QuicStreamId stream_id = i * 2; |
| 465 string path = partial_push_resource_path + base::UintToString(i); | 466 string path = |
| 467 partial_push_resource_path + QuicTextUtils::Uint64ToString(i); |
| 466 string url = scheme + "://" + resource_host + path; | 468 string url = scheme + "://" + resource_host + path; |
| 467 GURL resource_url = GURL(url); | 469 GURL resource_url = GURL(url); |
| 468 string body(body_size, 'a'); | 470 string body(body_size, 'a'); |
| 469 response_cache_.AddSimpleResponse(resource_host, path, 200, body); | 471 response_cache_.AddSimpleResponse(resource_host, path, 200, body); |
| 470 push_resources.push_back(QuicHttpResponseCache::ServerPushInfo( | 472 push_resources.push_back(QuicHttpResponseCache::ServerPushInfo( |
| 471 resource_url, SpdyHeaderBlock(), kDefaultPriority, body)); | 473 resource_url, SpdyHeaderBlock(), kDefaultPriority, body)); |
| 472 // PUSH_PROMISED are sent for all the resources. | 474 // PUSH_PROMISED are sent for all the resources. |
| 473 EXPECT_CALL(*headers_stream_, | 475 EXPECT_CALL(*headers_stream_, |
| 474 WritePushPromiseMock(kClientDataStreamId1, stream_id, _)); | 476 WritePushPromiseMock(kClientDataStreamId1, stream_id, _)); |
| 475 if (i <= kMaxStreamsForTest) { | 477 if (i <= kMaxStreamsForTest) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); | 608 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); |
| 607 | 609 |
| 608 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); | 610 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); |
| 609 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); | 611 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); |
| 610 visitor_->OnRstStream(rst); | 612 visitor_->OnRstStream(rst); |
| 611 } | 613 } |
| 612 | 614 |
| 613 } // namespace | 615 } // namespace |
| 614 } // namespace test | 616 } // namespace test |
| 615 } // namespace net | 617 } // namespace net |
| OLD | NEW |