| 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 toy server specific QuicSession subclass. | 5 // A toy server specific QuicSession subclass. |
| 6 | 6 |
| 7 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_SERVER_SESSION_H_ | 7 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_SERVER_SESSION_H_ |
| 8 #define NET_TOOLS_QUIC_QUIC_SIMPLE_SERVER_SESSION_H_ | 8 #define NET_TOOLS_QUIC_QUIC_SIMPLE_SERVER_SESSION_H_ |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 SpdyPriority priority; | 57 SpdyPriority priority; |
| 58 bool is_cancelled; | 58 bool is_cancelled; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Takes ownership of |connection|. | 61 // Takes ownership of |connection|. |
| 62 QuicSimpleServerSession(const QuicConfig& config, | 62 QuicSimpleServerSession(const QuicConfig& config, |
| 63 QuicConnection* connection, | 63 QuicConnection* connection, |
| 64 QuicSession::Visitor* visitor, | 64 QuicSession::Visitor* visitor, |
| 65 QuicCryptoServerStream::Helper* helper, | 65 QuicCryptoServerStream::Helper* helper, |
| 66 const QuicCryptoServerConfig* crypto_config, | 66 const QuicCryptoServerConfig* crypto_config, |
| 67 QuicCompressedCertsCache* compressed_certs_cache); | 67 QuicCompressedCertsCache* compressed_certs_cache, |
| 68 QuicInMemoryCache* in_memory_cache); |
| 68 | 69 |
| 69 ~QuicSimpleServerSession() override; | 70 ~QuicSimpleServerSession() override; |
| 70 | 71 |
| 71 // When a stream is marked draining, it will decrease the number of open | 72 // When a stream is marked draining, it will decrease the number of open |
| 72 // streams. If it is an outgoing stream, try to open a new stream to send | 73 // streams. If it is an outgoing stream, try to open a new stream to send |
| 73 // remaing push responses. | 74 // remaing push responses. |
| 74 void StreamDraining(QuicStreamId id) override; | 75 void StreamDraining(QuicStreamId id) override; |
| 75 | 76 |
| 76 // Override base class to detact client sending data on server push stream. | 77 // Override base class to detact client sending data on server push stream. |
| 77 void OnStreamFrame(const QuicStreamFrame& frame) override; | 78 void OnStreamFrame(const QuicStreamFrame& frame) override; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 98 void HandleFrameOnNonexistentOutgoingStream(QuicStreamId stream_id) override; | 99 void HandleFrameOnNonexistentOutgoingStream(QuicStreamId stream_id) override; |
| 99 // Override to handle reseting locally preserved streams. | 100 // Override to handle reseting locally preserved streams. |
| 100 void HandleRstOnValidNonexistentStream( | 101 void HandleRstOnValidNonexistentStream( |
| 101 const QuicRstStreamFrame& frame) override; | 102 const QuicRstStreamFrame& frame) override; |
| 102 | 103 |
| 103 // QuicServerSessionBaseMethod: | 104 // QuicServerSessionBaseMethod: |
| 104 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( | 105 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( |
| 105 const QuicCryptoServerConfig* crypto_config, | 106 const QuicCryptoServerConfig* crypto_config, |
| 106 QuicCompressedCertsCache* compressed_certs_cache) override; | 107 QuicCompressedCertsCache* compressed_certs_cache) override; |
| 107 | 108 |
| 109 QuicInMemoryCache* in_memory_cache() { return in_memory_cache_; } |
| 110 |
| 108 private: | 111 private: |
| 109 friend class test::QuicSimpleServerSessionPeer; | 112 friend class test::QuicSimpleServerSessionPeer; |
| 110 | 113 |
| 111 // Create a server push headers block by copying request's headers block. | 114 // Create a server push headers block by copying request's headers block. |
| 112 // But replace or add these pseudo-headers as they are specific to each | 115 // But replace or add these pseudo-headers as they are specific to each |
| 113 // request: | 116 // request: |
| 114 // :authority, :path, :method, :scheme, referer. | 117 // :authority, :path, :method, :scheme, referer. |
| 115 // Copying the rest headers ensures they are the same as the original | 118 // Copying the rest headers ensures they are the same as the original |
| 116 // request, especially cookies. | 119 // request, especially cookies. |
| 117 SpdyHeaderBlock SynthesizePushRequestHeaders( | 120 SpdyHeaderBlock SynthesizePushRequestHeaders( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 143 QuicStreamId highest_promised_stream_id_; | 146 QuicStreamId highest_promised_stream_id_; |
| 144 | 147 |
| 145 // Promised streams which hasn't been created yet because of max_open_stream_ | 148 // Promised streams which hasn't been created yet because of max_open_stream_ |
| 146 // limit. New element is added to the end of the queue. | 149 // limit. New element is added to the end of the queue. |
| 147 // Since outgoing stream is created in sequence, stream_id of each element in | 150 // Since outgoing stream is created in sequence, stream_id of each element in |
| 148 // the queue also increases by 2 from previous one's. The front element's | 151 // the queue also increases by 2 from previous one's. The front element's |
| 149 // stream_id is always next_outgoing_stream_id_, and the last one is always | 152 // stream_id is always next_outgoing_stream_id_, and the last one is always |
| 150 // highest_promised_stream_id_. | 153 // highest_promised_stream_id_. |
| 151 std::deque<PromisedStreamInfo> promised_streams_; | 154 std::deque<PromisedStreamInfo> promised_streams_; |
| 152 | 155 |
| 156 QuicInMemoryCache* in_memory_cache_; // Not owned. |
| 157 |
| 153 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerSession); | 158 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerSession); |
| 154 }; | 159 }; |
| 155 | 160 |
| 156 } // namespace net | 161 } // namespace net |
| 157 | 162 |
| 158 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_SERVER_SESSION_H_ | 163 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_SERVER_SESSION_H_ |
| OLD | NEW |