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