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

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

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_client_session_base.cc ('k') | net/quic/core/quic_server_session_base.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 // A server specific QuicSession subclass. 5 // A server specific QuicSession subclass.
6 6
7 #ifndef NET_QUIC_QUIC_SERVER_SESSION_BASE_H_ 7 #ifndef NET_QUIC_QUIC_SERVER_SESSION_BASE_H_
8 #define NET_QUIC_QUIC_SERVER_SESSION_BASE_H_ 8 #define NET_QUIC_QUIC_SERVER_SESSION_BASE_H_
9 9
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 19 matching lines...) Expand all
30 class QuicCryptoServerConfig; 30 class QuicCryptoServerConfig;
31 class ReliableQuicStream; 31 class ReliableQuicStream;
32 32
33 namespace test { 33 namespace test {
34 class QuicServerSessionBasePeer; 34 class QuicServerSessionBasePeer;
35 class QuicSimpleServerSessionPeer; 35 class QuicSimpleServerSessionPeer;
36 } // namespace test 36 } // namespace test
37 37
38 class NET_EXPORT_PRIVATE QuicServerSessionBase : public QuicSpdySession { 38 class NET_EXPORT_PRIVATE QuicServerSessionBase : public QuicSpdySession {
39 public: 39 public:
40 // An interface from the session to the entity owning the session.
41 // This lets the session notify its owner (the Dispatcher) when the connection
42 // is closed, blocked, or added/removed from the time-wait std::list.
43 class Visitor {
44 public:
45 virtual ~Visitor() {}
46
47 // Called when the connection is closed.
48 virtual void OnConnectionClosed(QuicConnectionId connection_id,
49 QuicErrorCode error,
50 const std::string& error_details) = 0;
51
52 // Called when the session has become write blocked.
53 virtual void OnWriteBlocked(QuicBlockedWriterInterface* blocked_writer) = 0;
54
55 // Called after the given connection is added to the time-wait std::list.
56 virtual void OnConnectionAddedToTimeWaitList(
57 QuicConnectionId connection_id) = 0;
58
59 // Called before a packet is going to be processed by |session|.
60 virtual void OnPacketBeingDispatchedToSession(QuicSession* session) = 0;
61 };
62
63 // Does not take ownership of |connection|. |crypto_config| must outlive the 40 // Does not take ownership of |connection|. |crypto_config| must outlive the
64 // session. |helper| must outlive any created crypto streams. 41 // session. |helper| must outlive any created crypto streams.
65 QuicServerSessionBase(const QuicConfig& config, 42 QuicServerSessionBase(const QuicConfig& config,
66 QuicConnection* connection, 43 QuicConnection* connection,
67 Visitor* visitor, 44 QuicSession::Visitor* visitor,
68 QuicCryptoServerStream::Helper* helper, 45 QuicCryptoServerStream::Helper* helper,
69 const QuicCryptoServerConfig* crypto_config, 46 const QuicCryptoServerConfig* crypto_config,
70 QuicCompressedCertsCache* compressed_certs_cache); 47 QuicCompressedCertsCache* compressed_certs_cache);
71 48
72 // Override the base class to notify the owner of the connection close. 49 // Override the base class to cancel any ongoing asychronous crypto.
73 void OnConnectionClosed(QuicErrorCode error, 50 void OnConnectionClosed(QuicErrorCode error,
74 const std::string& error_details, 51 const std::string& error_details,
75 ConnectionCloseSource source) override; 52 ConnectionCloseSource source) override;
76 void OnWriteBlocked() override;
77 53
78 // Sends a server config update to the client, containing new bandwidth 54 // Sends a server config update to the client, containing new bandwidth
79 // estimate. 55 // estimate.
80 void OnCongestionWindowChange(QuicTime now) override; 56 void OnCongestionWindowChange(QuicTime now) override;
81 57
82 ~QuicServerSessionBase() override; 58 ~QuicServerSessionBase() override;
83 59
84 void Initialize() override; 60 void Initialize() override;
85 61
86 const QuicCryptoServerStreamBase* crypto_stream() const { 62 const QuicCryptoServerStreamBase* crypto_stream() const {
(...skipping 22 matching lines...) Expand all
109 // does error handling, including communicating the error to the client and 85 // does error handling, including communicating the error to the client and
110 // possibly closing the connection, and returns false. 86 // possibly closing the connection, and returns false.
111 bool ShouldCreateIncomingDynamicStream(QuicStreamId id) override; 87 bool ShouldCreateIncomingDynamicStream(QuicStreamId id) override;
112 88
113 virtual QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( 89 virtual QuicCryptoServerStreamBase* CreateQuicCryptoServerStream(
114 const QuicCryptoServerConfig* crypto_config, 90 const QuicCryptoServerConfig* crypto_config,
115 QuicCompressedCertsCache* compressed_certs_cache) = 0; 91 QuicCompressedCertsCache* compressed_certs_cache) = 0;
116 92
117 const QuicCryptoServerConfig* crypto_config() { return crypto_config_; } 93 const QuicCryptoServerConfig* crypto_config() { return crypto_config_; }
118 94
119 Visitor* visitor() { return visitor_; }
120
121 QuicCryptoServerStream::Helper* stream_helper() { return helper_; } 95 QuicCryptoServerStream::Helper* stream_helper() { return helper_; }
122 96
123 private: 97 private:
124 friend class test::QuicServerSessionBasePeer; 98 friend class test::QuicServerSessionBasePeer;
125 friend class test::QuicSimpleServerSessionPeer; 99 friend class test::QuicSimpleServerSessionPeer;
126 100
127 const QuicCryptoServerConfig* crypto_config_; 101 const QuicCryptoServerConfig* crypto_config_;
128 102
129 // The cache which contains most recently compressed certs. 103 // The cache which contains most recently compressed certs.
130 // Owned by QuicDispatcher. 104 // Owned by QuicDispatcher.
131 QuicCompressedCertsCache* compressed_certs_cache_; 105 QuicCompressedCertsCache* compressed_certs_cache_;
132 106
133 std::unique_ptr<QuicCryptoServerStreamBase> crypto_stream_; 107 std::unique_ptr<QuicCryptoServerStreamBase> crypto_stream_;
134 Visitor* visitor_;
135 108
136 // Pointer to the helper used to create crypto server streams. Must outlive 109 // Pointer to the helper used to create crypto server streams. Must outlive
137 // streams created via CreateQuicCryptoServerStream. 110 // streams created via CreateQuicCryptoServerStream.
138 QuicCryptoServerStream::Helper* helper_; 111 QuicCryptoServerStream::Helper* helper_;
139 112
140 // Whether bandwidth resumption is enabled for this connection. 113 // Whether bandwidth resumption is enabled for this connection.
141 bool bandwidth_resumption_enabled_; 114 bool bandwidth_resumption_enabled_;
142 115
143 // The most recent bandwidth estimate sent to the client. 116 // The most recent bandwidth estimate sent to the client.
144 QuicBandwidth bandwidth_estimate_sent_to_client_; 117 QuicBandwidth bandwidth_estimate_sent_to_client_;
(...skipping 13 matching lines...) Expand all
158 // should go away once we fix http://b//27897982 131 // should go away once we fix http://b//27897982
159 int32_t BandwidthToCachedParameterBytesPerSecond( 132 int32_t BandwidthToCachedParameterBytesPerSecond(
160 const QuicBandwidth& bandwidth); 133 const QuicBandwidth& bandwidth);
161 134
162 DISALLOW_COPY_AND_ASSIGN(QuicServerSessionBase); 135 DISALLOW_COPY_AND_ASSIGN(QuicServerSessionBase);
163 }; 136 };
164 137
165 } // namespace net 138 } // namespace net
166 139
167 #endif // NET_QUIC_QUIC_SERVER_SESSION_BASE_H_ 140 #endif // NET_QUIC_QUIC_SERVER_SESSION_BASE_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_client_session_base.cc ('k') | net/quic/core/quic_server_session_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698