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

Side by Side Diff: net/quic/core/quic_session.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
« no previous file with comments | « net/quic/core/quic_session.h ('k') | net/quic/core/quic_session_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_session.h" 5 #include "net/quic/core/quic_session.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 11 matching lines...) Expand all
22 using std::max; 22 using std::max;
23 using std::string; 23 using std::string;
24 using std::vector; 24 using std::vector;
25 using net::SpdyPriority; 25 using net::SpdyPriority;
26 26
27 namespace net { 27 namespace net {
28 28
29 #define ENDPOINT \ 29 #define ENDPOINT \
30 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ") 30 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ")
31 31
32 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config) 32 QuicSession::QuicSession(QuicConnection* connection,
33 Visitor* owner,
34 const QuicConfig& config)
33 : connection_(connection), 35 : connection_(connection),
36 visitor_(owner),
34 config_(config), 37 config_(config),
35 max_open_outgoing_streams_(kDefaultMaxStreamsPerConnection), 38 max_open_outgoing_streams_(kDefaultMaxStreamsPerConnection),
36 max_open_incoming_streams_(config_.GetMaxIncomingDynamicStreamsToSend()), 39 max_open_incoming_streams_(config_.GetMaxIncomingDynamicStreamsToSend()),
37 next_outgoing_stream_id_(perspective() == Perspective::IS_SERVER ? 2 : 3), 40 next_outgoing_stream_id_(perspective() == Perspective::IS_SERVER ? 2 : 3),
38 largest_peer_created_stream_id_( 41 largest_peer_created_stream_id_(
39 perspective() == Perspective::IS_SERVER ? 1 : 0), 42 perspective() == Perspective::IS_SERVER ? 1 : 0),
40 num_dynamic_incoming_streams_(0), 43 num_dynamic_incoming_streams_(0),
41 num_draining_incoming_streams_(0), 44 num_draining_incoming_streams_(0),
42 num_locally_closed_incoming_streams_highest_offset_(0), 45 num_locally_closed_incoming_streams_highest_offset_(0),
43 error_(QUIC_NO_ERROR), 46 error_(QUIC_NO_ERROR),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 105 }
103 106
104 stream->OnStreamReset(frame); 107 stream->OnStreamReset(frame);
105 } 108 }
106 109
107 void QuicSession::OnGoAway(const QuicGoAwayFrame& frame) { 110 void QuicSession::OnGoAway(const QuicGoAwayFrame& frame) {
108 DCHECK(frame.last_good_stream_id < next_outgoing_stream_id_); 111 DCHECK(frame.last_good_stream_id < next_outgoing_stream_id_);
109 } 112 }
110 113
111 void QuicSession::OnConnectionClosed(QuicErrorCode error, 114 void QuicSession::OnConnectionClosed(QuicErrorCode error,
112 const string& /*error_details*/, 115 const string& error_details,
113 ConnectionCloseSource source) { 116 ConnectionCloseSource source) {
114 DCHECK(!connection_->connected()); 117 DCHECK(!connection_->connected());
115 if (error_ == QUIC_NO_ERROR) { 118 if (error_ == QUIC_NO_ERROR) {
116 error_ = error; 119 error_ = error;
117 } 120 }
118 121
119 while (!dynamic_stream_map_.empty()) { 122 while (!dynamic_stream_map_.empty()) {
120 DynamicStreamMap::iterator it = dynamic_stream_map_.begin(); 123 DynamicStreamMap::iterator it = dynamic_stream_map_.begin();
121 QuicStreamId id = it->first; 124 QuicStreamId id = it->first;
122 it->second->OnConnectionClosed(error, source); 125 it->second->OnConnectionClosed(error, source);
123 // The stream should call CloseStream as part of OnConnectionClosed. 126 // The stream should call CloseStream as part of OnConnectionClosed.
124 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { 127 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) {
125 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed"; 128 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed";
126 CloseStream(id); 129 CloseStream(id);
127 } 130 }
128 } 131 }
132
133 if (visitor_) {
134 visitor_->OnConnectionClosed(connection_->connection_id(), error,
135 error_details);
136 }
137 }
138
139 void QuicSession::OnWriteBlocked() {
140 if (visitor_) {
141 visitor_->OnWriteBlocked(connection_);
142 }
129 } 143 }
130 144
131 void QuicSession::OnSuccessfulVersionNegotiation( 145 void QuicSession::OnSuccessfulVersionNegotiation(
132 const QuicVersion& /*version*/) {} 146 const QuicVersion& /*version*/) {}
133 147
134 void QuicSession::OnPathDegrading() {} 148 void QuicSession::OnPathDegrading() {}
135 149
136 void QuicSession::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { 150 void QuicSession::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) {
137 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't 151 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't
138 // assume that it still exists. 152 // assume that it still exists.
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 821
808 size_t QuicSession::MaxAvailableStreams() const { 822 size_t QuicSession::MaxAvailableStreams() const {
809 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; 823 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier;
810 } 824 }
811 825
812 bool QuicSession::IsIncomingStream(QuicStreamId id) const { 826 bool QuicSession::IsIncomingStream(QuicStreamId id) const {
813 return id % 2 != next_outgoing_stream_id_ % 2; 827 return id % 2 != next_outgoing_stream_id_ % 2;
814 } 828 }
815 829
816 } // namespace net 830 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_session.h ('k') | net/quic/core/quic_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698