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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 server_push_enabled_ = | 57 server_push_enabled_ = |
58 ContainsQuicTag(config()->ReceivedConnectionOptions(), kSPSH); | 58 ContainsQuicTag(config()->ReceivedConnectionOptions(), kSPSH); |
59 | 59 |
60 // 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 |
61 // 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 |
62 // resumption. | 62 // resumption. |
63 const CachedNetworkParameters* cached_network_params = | 63 const CachedNetworkParameters* cached_network_params = |
64 crypto_stream_->PreviousCachedNetworkParams(); | 64 crypto_stream_->PreviousCachedNetworkParams(); |
65 if (cached_network_params != nullptr && | 65 if (cached_network_params != nullptr && |
66 cached_network_params->serving_region() == serving_region_) { | 66 cached_network_params->serving_region() == serving_region_) { |
67 if (FLAGS_quic_log_received_parameters) { | 67 // Log the received connection parameters, regardless of how they |
68 connection()->OnReceiveConnectionState(*cached_network_params); | 68 // get used for bandwidth resumption. |
69 } | 69 connection()->OnReceiveConnectionState(*cached_network_params); |
70 | 70 |
71 if (bandwidth_resumption_enabled_) { | 71 if (bandwidth_resumption_enabled_) { |
72 // Only do bandwidth resumption if estimate is recent enough. | 72 // Only do bandwidth resumption if estimate is recent enough. |
73 const int64_t seconds_since_estimate = | 73 const int64_t seconds_since_estimate = |
74 connection()->clock()->WallNow().ToUNIXSeconds() - | 74 connection()->clock()->WallNow().ToUNIXSeconds() - |
75 cached_network_params->timestamp(); | 75 cached_network_params->timestamp(); |
76 if (seconds_since_estimate <= kNumSecondsPerHour) { | 76 if (seconds_since_estimate <= kNumSecondsPerHour) { |
77 connection()->ResumeConnectionState(*cached_network_params, | 77 connection()->ResumeConnectionState(*cached_network_params, |
78 max_bandwidth_resumption); | 78 max_bandwidth_resumption); |
79 } | 79 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 int32_t QuicServerSessionBase::BandwidthToCachedParameterBytesPerSecond( | 235 int32_t QuicServerSessionBase::BandwidthToCachedParameterBytesPerSecond( |
236 const QuicBandwidth& bandwidth) { | 236 const QuicBandwidth& bandwidth) { |
237 int64_t bytes_per_second = bandwidth.ToBytesPerSecond(); | 237 int64_t bytes_per_second = bandwidth.ToBytesPerSecond(); |
238 return (bytes_per_second > static_cast<int64_t>(INT32_MAX) | 238 return (bytes_per_second > static_cast<int64_t>(INT32_MAX) |
239 ? INT32_MAX | 239 ? INT32_MAX |
240 : static_cast<int32_t>(bytes_per_second)); | 240 : static_cast<int32_t>(bytes_per_second)); |
241 } | 241 } |
242 | 242 |
243 } // namespace net | 243 } // namespace net |
OLD | NEW |