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 #ifndef NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ |
6 #define NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ | 6 #define NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <map> | 11 #include <map> |
9 #include <string> | 12 #include <string> |
10 #include <vector> | 13 #include <vector> |
11 | 14 |
12 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
14 #include "net/spdy/buffered_spdy_framer.h" | 17 #include "net/spdy/buffered_spdy_framer.h" |
15 #include "net/spdy/spdy_protocol.h" | 18 #include "net/spdy/spdy_protocol.h" |
16 #include "net/tools/balsa/balsa_headers.h" | 19 #include "net/tools/balsa/balsa_headers.h" |
17 #include "net/tools/balsa/balsa_visitor_interface.h" | 20 #include "net/tools/balsa/balsa_visitor_interface.h" |
(...skipping 10 matching lines...) Expand all Loading... |
28 public: | 31 public: |
29 SpdySM(SMConnection* connection, | 32 SpdySM(SMConnection* connection, |
30 SMInterface* sm_http_interface, | 33 SMInterface* sm_http_interface, |
31 EpollServer* epoll_server, | 34 EpollServer* epoll_server, |
32 MemoryCache* memory_cache, | 35 MemoryCache* memory_cache, |
33 FlipAcceptor* acceptor, | 36 FlipAcceptor* acceptor, |
34 SpdyMajorVersion spdy_version); | 37 SpdyMajorVersion spdy_version); |
35 ~SpdySM() override; | 38 ~SpdySM() override; |
36 | 39 |
37 void InitSMInterface(SMInterface* sm_http_interface, | 40 void InitSMInterface(SMInterface* sm_http_interface, |
38 int32 server_idx) override {} | 41 int32_t server_idx) override {} |
39 | 42 |
40 void InitSMConnection(SMConnectionPoolInterface* connection_pool, | 43 void InitSMConnection(SMConnectionPoolInterface* connection_pool, |
41 SMInterface* sm_interface, | 44 SMInterface* sm_interface, |
42 EpollServer* epoll_server, | 45 EpollServer* epoll_server, |
43 int fd, | 46 int fd, |
44 std::string server_ip, | 47 std::string server_ip, |
45 std::string server_port, | 48 std::string server_port, |
46 std::string remote_ip, | 49 std::string remote_ip, |
47 bool use_ssl) override; | 50 bool use_ssl) override; |
48 | 51 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // |end_headers| is true if there will not be any subsequent CONTINUATION | 125 // |end_headers| is true if there will not be any subsequent CONTINUATION |
123 // frames. | 126 // frames. |
124 void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override; | 127 void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override; |
125 | 128 |
126 // Called when a SETTINGS frame is received. | 129 // Called when a SETTINGS frame is received. |
127 // |clear_persisted| True if the respective flag is set on the SETTINGS frame. | 130 // |clear_persisted| True if the respective flag is set on the SETTINGS frame. |
128 void OnSettings(bool clear_persisted) override {} | 131 void OnSettings(bool clear_persisted) override {} |
129 | 132 |
130 // Called when an individual setting within a SETTINGS frame has been parsed | 133 // Called when an individual setting within a SETTINGS frame has been parsed |
131 // and validated. | 134 // and validated. |
132 void OnSetting(SpdySettingsIds id, uint8 flags, uint32 value) override {} | 135 void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override {} |
133 | 136 |
134 // Called when a PING frame has been parsed. | 137 // Called when a PING frame has been parsed. |
135 void OnPing(SpdyPingId unique_id, bool is_ack) override {} | 138 void OnPing(SpdyPingId unique_id, bool is_ack) override {} |
136 | 139 |
137 // Called when a RST_STREAM frame has been parsed. | 140 // Called when a RST_STREAM frame has been parsed. |
138 void OnRstStream(SpdyStreamId stream_id, SpdyRstStreamStatus status) override; | 141 void OnRstStream(SpdyStreamId stream_id, SpdyRstStreamStatus status) override; |
139 | 142 |
140 // Called when a GOAWAY frame has been parsed. | 143 // Called when a GOAWAY frame has been parsed. |
141 void OnGoAway(SpdyStreamId last_accepted_stream_id, | 144 void OnGoAway(SpdyStreamId last_accepted_stream_id, |
142 SpdyGoAwayStatus status, | 145 SpdyGoAwayStatus status, |
143 base::StringPiece debug_data) override {} | 146 base::StringPiece debug_data) override {} |
144 | 147 |
145 // Called when a WINDOW_UPDATE frame has been parsed. | 148 // Called when a WINDOW_UPDATE frame has been parsed. |
146 void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) override {} | 149 void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) override {} |
147 | 150 |
148 // Called when a PUSH_PROMISE frame has been parsed. | 151 // Called when a PUSH_PROMISE frame has been parsed. |
149 void OnPushPromise(SpdyStreamId stream_id, | 152 void OnPushPromise(SpdyStreamId stream_id, |
150 SpdyStreamId promised_stream_id, | 153 SpdyStreamId promised_stream_id, |
151 const SpdyHeaderBlock& headers) override {} | 154 const SpdyHeaderBlock& headers) override {} |
152 | 155 |
153 bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override; | 156 bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override; |
154 | 157 |
155 public: | 158 public: |
156 size_t ProcessReadInput(const char* data, size_t len) override; | 159 size_t ProcessReadInput(const char* data, size_t len) override; |
157 size_t ProcessWriteInput(const char* data, size_t len) override; | 160 size_t ProcessWriteInput(const char* data, size_t len) override; |
158 bool MessageFullyRead() const override; | 161 bool MessageFullyRead() const override; |
159 void SetStreamID(uint32 stream_id) override {} | 162 void SetStreamID(uint32_t stream_id) override {} |
160 bool Error() const override; | 163 bool Error() const override; |
161 const char* ErrorAsString() const override; | 164 const char* ErrorAsString() const override; |
162 void Reset() override {} | 165 void Reset() override {} |
163 void ResetForNewInterface(int32 server_idx) override; | 166 void ResetForNewInterface(int32_t server_idx) override; |
164 void ResetForNewConnection() override; | 167 void ResetForNewConnection() override; |
165 // SMInterface's Cleanup is currently only called by SMConnection after a | 168 // SMInterface's Cleanup is currently only called by SMConnection after a |
166 // protocol message as been fully read. Spdy's SMInterface does not need | 169 // protocol message as been fully read. Spdy's SMInterface does not need |
167 // to do any cleanup at this time. | 170 // to do any cleanup at this time. |
168 // TODO(klindsay) This method is probably not being used properly and | 171 // TODO(klindsay) This method is probably not being used properly and |
169 // some logic review and method renaming is probably in order. | 172 // some logic review and method renaming is probably in order. |
170 void Cleanup() override {} | 173 void Cleanup() override {} |
171 // Send a settings frame | 174 // Send a settings frame |
172 int PostAcceptHook() override; | 175 int PostAcceptHook() override; |
173 void NewStream(uint32 stream_id, | 176 void NewStream(uint32_t stream_id, |
174 uint32 priority, | 177 uint32_t priority, |
175 const std::string& filename) override; | 178 const std::string& filename) override; |
176 void AddToOutputOrder(const MemCacheIter& mci); | 179 void AddToOutputOrder(const MemCacheIter& mci); |
177 void SendEOF(uint32 stream_id) override; | 180 void SendEOF(uint32_t stream_id) override; |
178 void SendErrorNotFound(uint32 stream_id) override; | 181 void SendErrorNotFound(uint32_t stream_id) override; |
179 size_t SendSynStream(uint32 stream_id, const BalsaHeaders& headers) override; | 182 size_t SendSynStream(uint32_t stream_id, |
180 size_t SendSynReply(uint32 stream_id, const BalsaHeaders& headers) override; | 183 const BalsaHeaders& headers) override; |
181 void SendDataFrame(uint32 stream_id, | 184 size_t SendSynReply(uint32_t stream_id, const BalsaHeaders& headers) override; |
| 185 void SendDataFrame(uint32_t stream_id, |
182 const char* data, | 186 const char* data, |
183 int64 len, | 187 int64_t len, |
184 uint32 flags, | 188 uint32_t flags, |
185 bool compress) override; | 189 bool compress) override; |
186 BufferedSpdyFramer* spdy_framer() { return buffered_spdy_framer_.get(); } | 190 BufferedSpdyFramer* spdy_framer() { return buffered_spdy_framer_.get(); } |
187 | 191 |
188 const OutputOrdering& output_ordering() const { | 192 const OutputOrdering& output_ordering() const { |
189 return client_output_ordering_; | 193 return client_output_ordering_; |
190 } | 194 } |
191 | 195 |
192 static std::string forward_ip_header() { return forward_ip_header_; } | 196 static std::string forward_ip_header() { return forward_ip_header_; } |
193 static void set_forward_ip_header(const std::string& value) { | 197 static void set_forward_ip_header(const std::string& value) { |
194 forward_ip_header_ = value; | 198 forward_ip_header_ = value; |
195 } | 199 } |
196 SpdyMajorVersion spdy_version() const { | 200 SpdyMajorVersion spdy_version() const { |
197 DCHECK(buffered_spdy_framer_); | 201 DCHECK(buffered_spdy_framer_); |
198 return buffered_spdy_framer_->protocol_version(); | 202 return buffered_spdy_framer_->protocol_version(); |
199 } | 203 } |
200 | 204 |
201 private: | 205 private: |
202 void SendEOFImpl(uint32 stream_id); | 206 void SendEOFImpl(uint32_t stream_id); |
203 void SendErrorNotFoundImpl(uint32 stream_id); | 207 void SendErrorNotFoundImpl(uint32_t stream_id); |
204 void KillStream(uint32 stream_id); | 208 void KillStream(uint32_t stream_id); |
205 void CopyHeaders(SpdyHeaderBlock& dest, const BalsaHeaders& headers); | 209 void CopyHeaders(SpdyHeaderBlock& dest, const BalsaHeaders& headers); |
206 size_t SendSynStreamImpl(uint32 stream_id, const BalsaHeaders& headers); | 210 size_t SendSynStreamImpl(uint32_t stream_id, const BalsaHeaders& headers); |
207 size_t SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers); | 211 size_t SendSynReplyImpl(uint32_t stream_id, const BalsaHeaders& headers); |
208 void SendDataFrameImpl(uint32 stream_id, | 212 void SendDataFrameImpl(uint32_t stream_id, |
209 const char* data, | 213 const char* data, |
210 int64 len, | 214 int64_t len, |
211 SpdyDataFlags flags, | 215 SpdyDataFlags flags, |
212 bool compress); | 216 bool compress); |
213 void EnqueueDataFrame(DataFrame* df); | 217 void EnqueueDataFrame(DataFrame* df); |
214 void GetOutput() override; | 218 void GetOutput() override; |
215 | 219 |
216 private: | 220 private: |
217 scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_; | 221 scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_; |
218 bool valid_spdy_session_; // True if we have seen valid data on this session. | 222 bool valid_spdy_session_; // True if we have seen valid data on this session. |
219 // Use this to fail fast when junk is sent to our | 223 // Use this to fail fast when junk is sent to our |
220 // port. | 224 // port. |
221 | 225 |
222 SMConnection* connection_; | 226 SMConnection* connection_; |
223 OutputList* client_output_list_; | 227 OutputList* client_output_list_; |
224 OutputOrdering client_output_ordering_; | 228 OutputOrdering client_output_ordering_; |
225 uint32 next_outgoing_stream_id_; | 229 uint32_t next_outgoing_stream_id_; |
226 EpollServer* epoll_server_; | 230 EpollServer* epoll_server_; |
227 FlipAcceptor* acceptor_; | 231 FlipAcceptor* acceptor_; |
228 MemoryCache* memory_cache_; | 232 MemoryCache* memory_cache_; |
229 std::vector<SMInterface*> server_interface_list; | 233 std::vector<SMInterface*> server_interface_list; |
230 std::vector<int32> unused_server_interface_list; | 234 std::vector<int32_t> unused_server_interface_list; |
231 typedef std::map<uint32, SMInterface*> StreamToSmif; | 235 typedef std::map<uint32_t, SMInterface*> StreamToSmif; |
232 StreamToSmif stream_to_smif_; | 236 StreamToSmif stream_to_smif_; |
233 bool close_on_error_; | 237 bool close_on_error_; |
234 | 238 |
235 static std::string forward_ip_header_; | 239 static std::string forward_ip_header_; |
236 }; | 240 }; |
237 | 241 |
238 } // namespace net | 242 } // namespace net |
239 | 243 |
240 #endif // NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ | 244 #endif // NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ |
OLD | NEW |