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

Side by Side Diff: net/quic/quic_session.cc

Issue 1659733003: Remove VisitorShim and move shim behavior into QuicConnection. No (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@112975672
Patch Set: Created 4 years, 10 months 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/quic_session.h ('k') | net/quic/test_tools/quic_test_utils.h » ('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/quic_session.h" 5 #include "net/quic/quic_session.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/quic/crypto/proof_verifier.h" 10 #include "net/quic/crypto/proof_verifier.h"
(...skipping 12 matching lines...) Expand all
23 using std::max; 23 using std::max;
24 using std::string; 24 using std::string;
25 using std::vector; 25 using std::vector;
26 using net::SpdyPriority; 26 using net::SpdyPriority;
27 27
28 namespace net { 28 namespace net {
29 29
30 #define ENDPOINT \ 30 #define ENDPOINT \
31 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ") 31 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ")
32 32
33 // We want to make sure we delete any closed streams in a safe manner.
34 // To avoid deleting a stream in mid-operation, we have a simple shim between
35 // us and the stream, so we can delete any streams when we return from
36 // processing.
37 //
38 // We could just override the base methods, but this makes it easier to make
39 // sure we don't miss any.
40 class VisitorShim : public QuicConnectionVisitorInterface {
41 public:
42 explicit VisitorShim(QuicSession* session) : session_(session) {}
43
44 void OnStreamFrame(const QuicStreamFrame& frame) override {
45 session_->OnStreamFrame(frame);
46 session_->PostProcessAfterData();
47 }
48 void OnRstStream(const QuicRstStreamFrame& frame) override {
49 session_->OnRstStream(frame);
50 session_->PostProcessAfterData();
51 }
52
53 void OnGoAway(const QuicGoAwayFrame& frame) override {
54 session_->OnGoAway(frame);
55 session_->PostProcessAfterData();
56 }
57
58 void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override {
59 session_->OnWindowUpdateFrame(frame);
60 session_->PostProcessAfterData();
61 }
62
63 void OnBlockedFrame(const QuicBlockedFrame& frame) override {
64 session_->OnBlockedFrame(frame);
65 session_->PostProcessAfterData();
66 }
67
68 void OnCanWrite() override {
69 session_->OnCanWrite();
70 session_->PostProcessAfterData();
71 }
72
73 void OnCongestionWindowChange(QuicTime now) override {
74 session_->OnCongestionWindowChange(now);
75 }
76
77 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override {
78 session_->OnSuccessfulVersionNegotiation(version);
79 }
80
81 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override {
82 session_->OnConnectionClosed(error, from_peer);
83 // The session will go away, so don't bother with cleanup.
84 }
85
86 void OnWriteBlocked() override { session_->OnWriteBlocked(); }
87
88 void OnConnectionMigration() override { session_->OnConnectionMigration(); }
89
90 bool WillingAndAbleToWrite() const override {
91 return session_->WillingAndAbleToWrite();
92 }
93
94 bool HasPendingHandshake() const override {
95 return session_->HasPendingHandshake();
96 }
97
98 bool HasOpenDynamicStreams() const override {
99 return session_->HasOpenDynamicStreams();
100 }
101
102 private:
103 QuicSession* session_;
104 };
105
106 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config) 33 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config)
107 : connection_(connection), 34 : connection_(connection),
108 visitor_shim_(new VisitorShim(this)),
109 config_(config), 35 config_(config),
110 max_open_streams_(config_.MaxStreamsPerConnection()), 36 max_open_streams_(config_.MaxStreamsPerConnection()),
111 next_outgoing_stream_id_(perspective() == Perspective::IS_SERVER ? 2 : 3), 37 next_outgoing_stream_id_(perspective() == Perspective::IS_SERVER ? 2 : 3),
112 largest_peer_created_stream_id_( 38 largest_peer_created_stream_id_(
113 perspective() == Perspective::IS_SERVER ? 1 : 0), 39 perspective() == Perspective::IS_SERVER ? 1 : 0),
114 num_dynamic_incoming_streams_(0), 40 num_dynamic_incoming_streams_(0),
115 num_draining_incoming_streams_(0), 41 num_draining_incoming_streams_(0),
116 num_locally_closed_incoming_streams_highest_offset_(0), 42 num_locally_closed_incoming_streams_highest_offset_(0),
117 error_(QUIC_NO_ERROR), 43 error_(QUIC_NO_ERROR),
118 flow_controller_(connection_.get(), 44 flow_controller_(connection_.get(),
119 0, 45 0,
120 perspective(), 46 perspective(),
121 kMinimumFlowControlSendWindow, 47 kMinimumFlowControlSendWindow,
122 config_.GetInitialSessionFlowControlWindowToSend(), 48 config_.GetInitialSessionFlowControlWindowToSend(),
123 false), 49 false),
124 currently_writing_stream_id_(0) {} 50 currently_writing_stream_id_(0) {}
125 51
126 void QuicSession::Initialize() { 52 void QuicSession::Initialize() {
127 connection_->set_visitor(visitor_shim_.get()); 53 connection_->set_visitor(this);
128 connection_->SetFromConfig(config_); 54 connection_->SetFromConfig(config_);
129 55
130 DCHECK_EQ(kCryptoStreamId, GetCryptoStream()->id()); 56 DCHECK_EQ(kCryptoStreamId, GetCryptoStream()->id());
131 static_stream_map_[kCryptoStreamId] = GetCryptoStream(); 57 static_stream_map_[kCryptoStreamId] = GetCryptoStream();
132 } 58 }
133 59
134 QuicSession::~QuicSession() { 60 QuicSession::~QuicSession() {
135 STLDeleteElements(&closed_streams_); 61 STLDeleteElements(&closed_streams_);
136 STLDeleteValues(&dynamic_stream_map_); 62 STLDeleteValues(&dynamic_stream_map_);
137 63
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 806 }
881 } 807 }
882 return false; 808 return false;
883 } 809 }
884 810
885 bool QuicSession::IsIncomingStream(QuicStreamId id) const { 811 bool QuicSession::IsIncomingStream(QuicStreamId id) const {
886 return id % 2 != next_outgoing_stream_id_ % 2; 812 return id % 2 != next_outgoing_stream_id_ % 2;
887 } 813 }
888 814
889 } // namespace net 815 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698