Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: net/quic/core/quic_server_session_base.cc

Issue 2460163002: Refactor QuicServerSessionBase::Visitor (Closed)
Patch Set: Updated patchset dependency Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "net/quic/core/quic_flags.h" 11 #include "net/quic/core/quic_flags.h"
12 #include "net/quic/core/quic_spdy_session.h" 12 #include "net/quic/core/quic_spdy_session.h"
13 #include "net/quic/core/reliable_quic_stream.h" 13 #include "net/quic/core/reliable_quic_stream.h"
14 14
15 using std::string; 15 using std::string;
16 16
17 namespace net { 17 namespace net {
18 18
19 QuicServerSessionBase::QuicServerSessionBase( 19 QuicServerSessionBase::QuicServerSessionBase(
20 const QuicConfig& config, 20 const QuicConfig& config,
21 QuicConnection* connection, 21 QuicConnection* connection,
22 Visitor* visitor, 22 Visitor* visitor,
23 QuicCryptoServerStream::Helper* helper, 23 QuicCryptoServerStream::Helper* helper,
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, visitor, 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),
30 helper_(helper), 29 helper_(helper),
31 bandwidth_resumption_enabled_(false), 30 bandwidth_resumption_enabled_(false),
32 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()), 31 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()),
33 last_scup_time_(QuicTime::Zero()), 32 last_scup_time_(QuicTime::Zero()),
34 last_scup_packet_number_(0) {} 33 last_scup_packet_number_(0) {}
35 34
36 QuicServerSessionBase::~QuicServerSessionBase() {} 35 QuicServerSessionBase::~QuicServerSessionBase() {}
37 36
38 void QuicServerSessionBase::Initialize() { 37 void QuicServerSessionBase::Initialize() {
39 crypto_stream_.reset( 38 crypto_stream_.reset(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 87
89 void QuicServerSessionBase::OnConnectionClosed(QuicErrorCode error, 88 void QuicServerSessionBase::OnConnectionClosed(QuicErrorCode error,
90 const string& error_details, 89 const string& error_details,
91 ConnectionCloseSource source) { 90 ConnectionCloseSource source) {
92 QuicSession::OnConnectionClosed(error, error_details, source); 91 QuicSession::OnConnectionClosed(error, error_details, source);
93 // In the unlikely event we get a connection close while doing an asynchronous 92 // In the unlikely event we get a connection close while doing an asynchronous
94 // crypto event, make sure we cancel the callback. 93 // crypto event, make sure we cancel the callback.
95 if (crypto_stream_.get() != nullptr) { 94 if (crypto_stream_.get() != nullptr) {
96 crypto_stream_->CancelOutstandingCallbacks(); 95 crypto_stream_->CancelOutstandingCallbacks();
97 } 96 }
98 visitor_->OnConnectionClosed(connection()->connection_id(), error,
99 error_details);
100 }
101
102 void QuicServerSessionBase::OnWriteBlocked() {
103 QuicSession::OnWriteBlocked();
104 visitor_->OnWriteBlocked(connection());
105 } 97 }
106 98
107 void QuicServerSessionBase::OnCongestionWindowChange(QuicTime now) { 99 void QuicServerSessionBase::OnCongestionWindowChange(QuicTime now) {
108 if (!bandwidth_resumption_enabled_) { 100 if (!bandwidth_resumption_enabled_) {
109 return; 101 return;
110 } 102 }
111 // Only send updates when the application has no data to write. 103 // Only send updates when the application has no data to write.
112 if (HasDataToWrite()) { 104 if (HasDataToWrite()) {
113 return; 105 return;
114 } 106 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 232
241 int32_t QuicServerSessionBase::BandwidthToCachedParameterBytesPerSecond( 233 int32_t QuicServerSessionBase::BandwidthToCachedParameterBytesPerSecond(
242 const QuicBandwidth& bandwidth) { 234 const QuicBandwidth& bandwidth) {
243 int64_t bytes_per_second = bandwidth.ToBytesPerSecond(); 235 int64_t bytes_per_second = bandwidth.ToBytesPerSecond();
244 return (bytes_per_second > static_cast<int64_t>(INT32_MAX) 236 return (bytes_per_second > static_cast<int64_t>(INT32_MAX)
245 ? INT32_MAX 237 ? INT32_MAX
246 : static_cast<int32_t>(bytes_per_second)); 238 : static_cast<int32_t>(bytes_per_second));
247 } 239 }
248 240
249 } // namespace net 241 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_server_session_base.h ('k') | net/quic/core/quic_server_session_base_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698