| 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 // A QuicSession, which demuxes a single connection to individual streams. | 5 // A QuicSession, which demuxes a single connection to individual streams. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_QUIC_SESSION_H_ | 7 #ifndef NET_QUIC_QUIC_SESSION_H_ |
| 8 #define NET_QUIC_QUIC_SESSION_H_ | 8 #define NET_QUIC_QUIC_SESSION_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Returns mutable config for this session. Returned config is owned | 107 // Returns mutable config for this session. Returned config is owned |
| 108 // by QuicSession. | 108 // by QuicSession. |
| 109 QuicConfig* config(); | 109 QuicConfig* config(); |
| 110 | 110 |
| 111 // Returns true if the stream existed previously and has been closed. | 111 // Returns true if the stream existed previously and has been closed. |
| 112 // Returns false if the stream is still active or if the stream has | 112 // Returns false if the stream is still active or if the stream has |
| 113 // not yet been created. | 113 // not yet been created. |
| 114 bool IsClosedStream(QuicStreamId id); | 114 bool IsClosedStream(QuicStreamId id); |
| 115 | 115 |
| 116 QuicConnection* connection() { return connection_.get(); } | 116 QuicConnection* connection() { return connection_.get(); } |
| 117 const QuicConnection* connection() const { return connection_.get(); } | |
| 118 size_t num_active_requests() const { return stream_map_.size(); } | 117 size_t num_active_requests() const { return stream_map_.size(); } |
| 119 const IPEndPoint& peer_address() const { | 118 const IPEndPoint& peer_address() const { |
| 120 return connection_->peer_address(); | 119 return connection_->peer_address(); |
| 121 } | 120 } |
| 122 QuicGuid guid() const { return connection_->guid(); } | 121 QuicGuid guid() const { return connection_->guid(); } |
| 123 | 122 |
| 124 QuicPacketCreator::Options* options() { return connection()->options(); } | 123 QuicPacketCreator::Options* options() { return connection()->options(); } |
| 125 | 124 |
| 126 // Returns the number of currently open streams, including those which have | 125 // Returns the number of currently open streams, including those which have |
| 127 // been implicitly created. | 126 // been implicitly created. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 return goaway_received_; | 137 return goaway_received_; |
| 139 } | 138 } |
| 140 | 139 |
| 141 bool goaway_sent() const { | 140 bool goaway_sent() const { |
| 142 return goaway_sent_; | 141 return goaway_sent_; |
| 143 } | 142 } |
| 144 | 143 |
| 145 QuicSpdyDecompressor* decompressor() { return &decompressor_; } | 144 QuicSpdyDecompressor* decompressor() { return &decompressor_; } |
| 146 QuicSpdyCompressor* compressor() { return &compressor_; } | 145 QuicSpdyCompressor* compressor() { return &compressor_; } |
| 147 | 146 |
| 148 QuicErrorCode error() const { return error_; } | |
| 149 | |
| 150 protected: | 147 protected: |
| 151 // Creates a new stream, owned by the caller, to handle a peer-initiated | 148 // Creates a new stream, owned by the caller, to handle a peer-initiated |
| 152 // stream. Returns NULL and does error handling if the stream can not be | 149 // stream. Returns NULL and does error handling if the stream can not be |
| 153 // created. | 150 // created. |
| 154 virtual ReliableQuicStream* CreateIncomingReliableStream(QuicStreamId id) = 0; | 151 virtual ReliableQuicStream* CreateIncomingReliableStream(QuicStreamId id) = 0; |
| 155 | 152 |
| 156 // Create a new stream, owned by the caller, to handle a locally-initiated | 153 // Create a new stream, owned by the caller, to handle a locally-initiated |
| 157 // stream. Returns NULL if max streams have already been opened. | 154 // stream. Returns NULL if max streams have already been opened. |
| 158 virtual ReliableQuicStream* CreateOutgoingReliableStream() = 0; | 155 virtual ReliableQuicStream* CreateOutgoingReliableStream() = 0; |
| 159 | 156 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 170 | 167 |
| 171 // This is called after every call other than OnConnectionClose from the | 168 // This is called after every call other than OnConnectionClose from the |
| 172 // QuicConnectionVisitor to allow post-processing once the work has been done. | 169 // QuicConnectionVisitor to allow post-processing once the work has been done. |
| 173 // In this case, it deletes streams given that it's safe to do so (no other | 170 // In this case, it deletes streams given that it's safe to do so (no other |
| 174 // operations are being done on the streams at this time) | 171 // operations are being done on the streams at this time) |
| 175 virtual void PostProcessAfterData(); | 172 virtual void PostProcessAfterData(); |
| 176 | 173 |
| 177 base::hash_map<QuicStreamId, ReliableQuicStream*>* streams() { | 174 base::hash_map<QuicStreamId, ReliableQuicStream*>* streams() { |
| 178 return &stream_map_; | 175 return &stream_map_; |
| 179 } | 176 } |
| 180 | |
| 181 const base::hash_map<QuicStreamId, ReliableQuicStream*>* streams() const { | |
| 182 return &stream_map_; | |
| 183 } | |
| 184 | |
| 185 std::vector<ReliableQuicStream*>* closed_streams() { | 177 std::vector<ReliableQuicStream*>* closed_streams() { |
| 186 return &closed_streams_; | 178 return &closed_streams_; |
| 187 } | 179 } |
| 188 | 180 |
| 189 size_t get_max_open_streams() const { | 181 size_t get_max_open_streams() const { |
| 190 return max_open_streams_; | 182 return max_open_streams_; |
| 191 } | 183 } |
| 192 | 184 |
| 193 void set_max_open_streams(size_t max_open_streams) { | 185 void set_max_open_streams(size_t max_open_streams) { |
| 194 max_open_streams_ = max_open_streams; | 186 max_open_streams_ = max_open_streams; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 221 |
| 230 // A list of streams which need to write more data. | 222 // A list of streams which need to write more data. |
| 231 BlockedList<QuicStreamId> write_blocked_streams_; | 223 BlockedList<QuicStreamId> write_blocked_streams_; |
| 232 | 224 |
| 233 // A map of headers waiting to be compressed, and the streams | 225 // A map of headers waiting to be compressed, and the streams |
| 234 // they are associated with. | 226 // they are associated with. |
| 235 map<uint32, QuicStreamId> decompression_blocked_streams_; | 227 map<uint32, QuicStreamId> decompression_blocked_streams_; |
| 236 | 228 |
| 237 QuicStreamId largest_peer_created_stream_id_; | 229 QuicStreamId largest_peer_created_stream_id_; |
| 238 | 230 |
| 239 // The latched error with which the connection was closed. | |
| 240 QuicErrorCode error_; | |
| 241 | |
| 242 // Whether a GoAway has been received. | 231 // Whether a GoAway has been received. |
| 243 bool goaway_received_; | 232 bool goaway_received_; |
| 244 // Whether a GoAway has been sent. | 233 // Whether a GoAway has been sent. |
| 245 bool goaway_sent_; | 234 bool goaway_sent_; |
| 246 | 235 |
| 247 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 236 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
| 248 }; | 237 }; |
| 249 | 238 |
| 250 } // namespace net | 239 } // namespace net |
| 251 | 240 |
| 252 #endif // NET_QUIC_QUIC_SESSION_H_ | 241 #endif // NET_QUIC_QUIC_SESSION_H_ |
| OLD | NEW |