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/tools/quic/quic_server_session_base.h" | 5 #include "net/tools/quic/quic_server_session_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/proto/cached_network_parameters.pb.h" | 8 #include "net/quic/proto/cached_network_parameters.pb.h" |
9 #include "net/quic/quic_bug_tracker.h" | 9 #include "net/quic/quic_bug_tracker.h" |
10 #include "net/quic/quic_connection.h" | 10 #include "net/quic/quic_connection.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 QuicServerSessionVisitor* visitor, | 22 QuicServerSessionVisitor* visitor, |
23 const QuicCryptoServerConfig* crypto_config, | 23 const QuicCryptoServerConfig* crypto_config, |
24 QuicCompressedCertsCache* compressed_certs_cache) | 24 QuicCompressedCertsCache* compressed_certs_cache) |
25 : QuicSpdySession(connection, config), | 25 : QuicSpdySession(connection, config), |
26 crypto_config_(crypto_config), | 26 crypto_config_(crypto_config), |
27 compressed_certs_cache_(compressed_certs_cache), | 27 compressed_certs_cache_(compressed_certs_cache), |
28 visitor_(visitor), | 28 visitor_(visitor), |
29 bandwidth_resumption_enabled_(false), | 29 bandwidth_resumption_enabled_(false), |
30 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()), | 30 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()), |
31 last_scup_time_(QuicTime::Zero()), | 31 last_scup_time_(QuicTime::Zero()), |
32 last_scup_packet_number_(0) {} | 32 last_scup_packet_number_(0), |
| 33 server_push_enabled_(false) {} |
33 | 34 |
34 QuicServerSessionBase::~QuicServerSessionBase() {} | 35 QuicServerSessionBase::~QuicServerSessionBase() {} |
35 | 36 |
36 void QuicServerSessionBase::Initialize() { | 37 void QuicServerSessionBase::Initialize() { |
37 crypto_stream_.reset( | 38 crypto_stream_.reset( |
38 CreateQuicCryptoServerStream(crypto_config_, compressed_certs_cache_)); | 39 CreateQuicCryptoServerStream(crypto_config_, compressed_certs_cache_)); |
39 QuicSpdySession::Initialize(); | 40 QuicSpdySession::Initialize(); |
40 } | 41 } |
41 | 42 |
42 void QuicServerSessionBase::OnConfigNegotiated() { | 43 void QuicServerSessionBase::OnConfigNegotiated() { |
43 QuicSession::OnConfigNegotiated(); | 44 QuicSession::OnConfigNegotiated(); |
44 | 45 |
45 if (!config()->HasReceivedConnectionOptions()) { | 46 if (!config()->HasReceivedConnectionOptions()) { |
46 return; | 47 return; |
47 } | 48 } |
48 | 49 |
49 // Enable bandwidth resumption if peer sent correct connection options. | 50 // Enable bandwidth resumption if peer sent correct connection options. |
50 const bool last_bandwidth_resumption = | 51 const bool last_bandwidth_resumption = |
51 ContainsQuicTag(config()->ReceivedConnectionOptions(), kBWRE); | 52 ContainsQuicTag(config()->ReceivedConnectionOptions(), kBWRE); |
52 const bool max_bandwidth_resumption = | 53 const bool max_bandwidth_resumption = |
53 ContainsQuicTag(config()->ReceivedConnectionOptions(), kBWMX); | 54 ContainsQuicTag(config()->ReceivedConnectionOptions(), kBWMX); |
54 bandwidth_resumption_enabled_ = | 55 bandwidth_resumption_enabled_ = |
55 last_bandwidth_resumption || max_bandwidth_resumption; | 56 last_bandwidth_resumption || max_bandwidth_resumption; |
| 57 server_push_enabled_ = |
| 58 ContainsQuicTag(config()->ReceivedConnectionOptions(), kSPSH); |
56 | 59 |
57 // If the client has provided a bandwidth estimate from the same serving | 60 // If the client has provided a bandwidth estimate from the same serving |
58 // region as this server, then decide whether to use the data for bandwidth | 61 // region as this server, then decide whether to use the data for bandwidth |
59 // resumption. | 62 // resumption. |
60 const CachedNetworkParameters* cached_network_params = | 63 const CachedNetworkParameters* cached_network_params = |
61 crypto_stream_->PreviousCachedNetworkParams(); | 64 crypto_stream_->PreviousCachedNetworkParams(); |
62 if (cached_network_params != nullptr && | 65 if (cached_network_params != nullptr && |
63 cached_network_params->serving_region() == serving_region_) { | 66 cached_network_params->serving_region() == serving_region_) { |
64 if (FLAGS_quic_log_received_parameters) { | 67 if (FLAGS_quic_log_received_parameters) { |
65 connection()->OnReceiveConnectionState(*cached_network_params); | 68 connection()->OnReceiveConnectionState(*cached_network_params); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 234 |
232 int32_t QuicServerSessionBase::BandwidthToCachedParameterBytesPerSecond( | 235 int32_t QuicServerSessionBase::BandwidthToCachedParameterBytesPerSecond( |
233 const QuicBandwidth& bandwidth) { | 236 const QuicBandwidth& bandwidth) { |
234 int64_t bytes_per_second = bandwidth.ToBytesPerSecond(); | 237 int64_t bytes_per_second = bandwidth.ToBytesPerSecond(); |
235 return (bytes_per_second > static_cast<int64_t>(INT32_MAX) | 238 return (bytes_per_second > static_cast<int64_t>(INT32_MAX) |
236 ? INT32_MAX | 239 ? INT32_MAX |
237 : static_cast<int32_t>(bytes_per_second)); | 240 : static_cast<int32_t>(bytes_per_second)); |
238 } | 241 } |
239 | 242 |
240 } // namespace net | 243 } // namespace net |
OLD | NEW |