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_SPDY_BUFFERED_SPDY_FRAMER_H_ | 5 #ifndef NET_SPDY_BUFFERED_SPDY_FRAMER_H_ |
6 #define NET_SPDY_BUFFERED_SPDY_FRAMER_H_ | 6 #define NET_SPDY_BUFFERED_SPDY_FRAMER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
14 #include "net/socket/next_proto.h" | 14 #include "net/socket/next_proto.h" |
15 #include "net/spdy/spdy_framer.h" | 15 #include "net/spdy/spdy_framer.h" |
16 #include "net/spdy/spdy_header_block.h" | 16 #include "net/spdy/spdy_header_block.h" |
17 #include "net/spdy/spdy_protocol.h" | 17 #include "net/spdy/spdy_protocol.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 // Returns the SPDY major version corresponding to the given NextProto | 21 // Returns the SPDY major version corresponding to the given NextProto |
22 // value, which must represent a SPDY-like protocol. | 22 // value, which must represent a SPDY-like protocol. |
23 NET_EXPORT_PRIVATE SpdyMajorVersion NextProtoToSpdyMajorVersion( | 23 NET_EXPORT_PRIVATE SpdyMajorVersion |
24 NextProto next_proto); | 24 NextProtoToSpdyMajorVersion(NextProto next_proto); |
25 | 25 |
26 class NET_EXPORT_PRIVATE BufferedSpdyFramerVisitorInterface { | 26 class NET_EXPORT_PRIVATE BufferedSpdyFramerVisitorInterface { |
27 public: | 27 public: |
28 BufferedSpdyFramerVisitorInterface() {} | 28 BufferedSpdyFramerVisitorInterface() {} |
29 | 29 |
30 // Called if an error is detected in the SpdyFrame protocol. | 30 // Called if an error is detected in the SpdyFrame protocol. |
31 virtual void OnError(SpdyFramer::SpdyError error_code) = 0; | 31 virtual void OnError(SpdyFramer::SpdyError error_code) = 0; |
32 | 32 |
33 // Called if an error is detected in a SPDY stream. | 33 // Called if an error is detected in a SPDY stream. |
34 virtual void OnStreamError(SpdyStreamId stream_id, | 34 virtual void OnStreamError(SpdyStreamId stream_id, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 protected: | 105 protected: |
106 virtual ~BufferedSpdyFramerVisitorInterface() {} | 106 virtual ~BufferedSpdyFramerVisitorInterface() {} |
107 | 107 |
108 private: | 108 private: |
109 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramerVisitorInterface); | 109 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramerVisitorInterface); |
110 }; | 110 }; |
111 | 111 |
112 class NET_EXPORT_PRIVATE BufferedSpdyFramer | 112 class NET_EXPORT_PRIVATE BufferedSpdyFramer |
113 : public SpdyFramerVisitorInterface { | 113 : public SpdyFramerVisitorInterface { |
114 public: | 114 public: |
115 BufferedSpdyFramer(SpdyMajorVersion version, | 115 BufferedSpdyFramer(SpdyMajorVersion version, bool enable_compression); |
116 bool enable_compression); | |
117 virtual ~BufferedSpdyFramer(); | 116 virtual ~BufferedSpdyFramer(); |
118 | 117 |
119 // Sets callbacks to be called from the buffered spdy framer. A visitor must | 118 // Sets callbacks to be called from the buffered spdy framer. A visitor must |
120 // be set, or else the framer will likely crash. It is acceptable for the | 119 // be set, or else the framer will likely crash. It is acceptable for the |
121 // visitor to do nothing. If this is called multiple times, only the last | 120 // visitor to do nothing. If this is called multiple times, only the last |
122 // visitor will be used. | 121 // visitor will be used. |
123 void set_visitor(BufferedSpdyFramerVisitorInterface* visitor); | 122 void set_visitor(BufferedSpdyFramerVisitorInterface* visitor); |
124 | 123 |
125 // Set debug callbacks to be called from the framer. The debug visitor is | 124 // Set debug callbacks to be called from the framer. The debug visitor is |
126 // completely optional and need not be set in order for normal operation. | 125 // completely optional and need not be set in order for normal operation. |
(...skipping 10 matching lines...) Expand all Loading... |
137 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE; | 136 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE; |
138 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) OVERRIDE; | 137 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) OVERRIDE; |
139 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, | 138 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, |
140 const char* header_data, | 139 const char* header_data, |
141 size_t len) OVERRIDE; | 140 size_t len) OVERRIDE; |
142 virtual void OnStreamFrameData(SpdyStreamId stream_id, | 141 virtual void OnStreamFrameData(SpdyStreamId stream_id, |
143 const char* data, | 142 const char* data, |
144 size_t len, | 143 size_t len, |
145 bool fin) OVERRIDE; | 144 bool fin) OVERRIDE; |
146 virtual void OnSettings(bool clear_persisted) OVERRIDE; | 145 virtual void OnSettings(bool clear_persisted) OVERRIDE; |
147 virtual void OnSetting( | 146 virtual void OnSetting(SpdySettingsIds id, |
148 SpdySettingsIds id, uint8 flags, uint32 value) OVERRIDE; | 147 uint8 flags, |
| 148 uint32 value) OVERRIDE; |
149 virtual void OnSettingsAck() OVERRIDE; | 149 virtual void OnSettingsAck() OVERRIDE; |
150 virtual void OnSettingsEnd() OVERRIDE; | 150 virtual void OnSettingsEnd() OVERRIDE; |
151 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE; | 151 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE; |
152 virtual void OnRstStream(SpdyStreamId stream_id, | 152 virtual void OnRstStream(SpdyStreamId stream_id, |
153 SpdyRstStreamStatus status) OVERRIDE; | 153 SpdyRstStreamStatus status) OVERRIDE; |
154 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, | 154 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, |
155 SpdyGoAwayStatus status) OVERRIDE; | 155 SpdyGoAwayStatus status) OVERRIDE; |
156 virtual void OnWindowUpdate(SpdyStreamId stream_id, | 156 virtual void OnWindowUpdate(SpdyStreamId stream_id, |
157 uint32 delta_window_size) OVERRIDE; | 157 uint32 delta_window_size) OVERRIDE; |
158 virtual void OnPushPromise(SpdyStreamId stream_id, | 158 virtual void OnPushPromise(SpdyStreamId stream_id, |
(...skipping 17 matching lines...) Expand all Loading... |
176 SpdyPriority priority, | 176 SpdyPriority priority, |
177 SpdyControlFlags flags, | 177 SpdyControlFlags flags, |
178 const SpdyHeaderBlock* headers); | 178 const SpdyHeaderBlock* headers); |
179 SpdyFrame* CreateSynReply(SpdyStreamId stream_id, | 179 SpdyFrame* CreateSynReply(SpdyStreamId stream_id, |
180 SpdyControlFlags flags, | 180 SpdyControlFlags flags, |
181 const SpdyHeaderBlock* headers); | 181 const SpdyHeaderBlock* headers); |
182 SpdyFrame* CreateRstStream(SpdyStreamId stream_id, | 182 SpdyFrame* CreateRstStream(SpdyStreamId stream_id, |
183 SpdyRstStreamStatus status) const; | 183 SpdyRstStreamStatus status) const; |
184 SpdyFrame* CreateSettings(const SettingsMap& values) const; | 184 SpdyFrame* CreateSettings(const SettingsMap& values) const; |
185 SpdyFrame* CreatePingFrame(uint32 unique_id, bool is_ack) const; | 185 SpdyFrame* CreatePingFrame(uint32 unique_id, bool is_ack) const; |
186 SpdyFrame* CreateGoAway( | 186 SpdyFrame* CreateGoAway(SpdyStreamId last_accepted_stream_id, |
187 SpdyStreamId last_accepted_stream_id, | 187 SpdyGoAwayStatus status) const; |
188 SpdyGoAwayStatus status) const; | |
189 SpdyFrame* CreateHeaders(SpdyStreamId stream_id, | 188 SpdyFrame* CreateHeaders(SpdyStreamId stream_id, |
190 SpdyControlFlags flags, | 189 SpdyControlFlags flags, |
191 const SpdyHeaderBlock* headers); | 190 const SpdyHeaderBlock* headers); |
192 SpdyFrame* CreateWindowUpdate( | 191 SpdyFrame* CreateWindowUpdate(SpdyStreamId stream_id, |
193 SpdyStreamId stream_id, | 192 uint32 delta_window_size) const; |
194 uint32 delta_window_size) const; | |
195 SpdyFrame* CreateDataFrame(SpdyStreamId stream_id, | 193 SpdyFrame* CreateDataFrame(SpdyStreamId stream_id, |
196 const char* data, | 194 const char* data, |
197 uint32 len, | 195 uint32 len, |
198 SpdyDataFlags flags); | 196 SpdyDataFlags flags); |
199 | 197 |
200 // Serialize a frame of unknown type. | 198 // Serialize a frame of unknown type. |
201 SpdySerializedFrame* SerializeFrame(const SpdyFrameIR& frame) { | 199 SpdySerializedFrame* SerializeFrame(const SpdyFrameIR& frame) { |
202 return spdy_framer_.SerializeFrame(frame); | 200 return spdy_framer_.SerializeFrame(frame); |
203 } | 201 } |
204 | 202 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 bool unidirectional; | 256 bool unidirectional; |
259 }; | 257 }; |
260 scoped_ptr<ControlFrameFields> control_frame_fields_; | 258 scoped_ptr<ControlFrameFields> control_frame_fields_; |
261 | 259 |
262 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramer); | 260 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramer); |
263 }; | 261 }; |
264 | 262 |
265 } // namespace net | 263 } // namespace net |
266 | 264 |
267 #endif // NET_SPDY_BUFFERED_SPDY_FRAMER_H_ | 265 #endif // NET_SPDY_BUFFERED_SPDY_FRAMER_H_ |
OLD | NEW |