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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 #include "net/socket/next_proto.h" | |
17 #include "net/spdy/header_coalescer.h" | 16 #include "net/spdy/header_coalescer.h" |
18 #include "net/spdy/spdy_alt_svc_wire_format.h" | 17 #include "net/spdy/spdy_alt_svc_wire_format.h" |
19 #include "net/spdy/spdy_framer.h" | 18 #include "net/spdy/spdy_framer.h" |
20 #include "net/spdy/spdy_header_block.h" | 19 #include "net/spdy/spdy_header_block.h" |
21 #include "net/spdy/spdy_protocol.h" | 20 #include "net/spdy/spdy_protocol.h" |
22 | 21 |
23 namespace net { | 22 namespace net { |
24 | 23 |
25 // Returns the SPDY major version corresponding to the given NextProto | |
26 // value, which must represent a SPDY-like protocol. | |
27 NET_EXPORT_PRIVATE SpdyMajorVersion NextProtoToSpdyMajorVersion( | |
28 NextProto next_proto); | |
29 | |
30 class NET_EXPORT_PRIVATE BufferedSpdyFramerVisitorInterface { | 24 class NET_EXPORT_PRIVATE BufferedSpdyFramerVisitorInterface { |
31 public: | 25 public: |
32 BufferedSpdyFramerVisitorInterface() {} | 26 BufferedSpdyFramerVisitorInterface() {} |
33 | 27 |
34 // Called if an error is detected in the SpdySerializedFrame protocol. | 28 // Called if an error is detected in the SpdySerializedFrame protocol. |
35 virtual void OnError(SpdyFramer::SpdyError error_code) = 0; | 29 virtual void OnError(SpdyFramer::SpdyError error_code) = 0; |
36 | 30 |
37 // Called if an error is detected in a SPDY stream. | 31 // Called if an error is detected in a SPDY stream. |
38 virtual void OnStreamError(SpdyStreamId stream_id, | 32 virtual void OnStreamError(SpdyStreamId stream_id, |
39 const std::string& description) = 0; | 33 const std::string& description) = 0; |
40 | 34 |
41 // Called after all the header data for SYN_STREAM control frame is received. | |
42 virtual void OnSynStream(SpdyStreamId stream_id, | |
43 SpdyStreamId associated_stream_id, | |
44 SpdyPriority priority, | |
45 bool fin, | |
46 bool unidirectional, | |
47 const SpdyHeaderBlock& headers) = 0; | |
48 | |
49 // Called after all the header data for SYN_REPLY control frame is received. | |
50 virtual void OnSynReply(SpdyStreamId stream_id, | |
51 bool fin, | |
52 const SpdyHeaderBlock& headers) = 0; | |
53 | |
54 // Called after all the header data for HEADERS control frame is received. | 35 // Called after all the header data for HEADERS control frame is received. |
55 virtual void OnHeaders(SpdyStreamId stream_id, | 36 virtual void OnHeaders(SpdyStreamId stream_id, |
56 bool has_priority, | 37 bool has_priority, |
57 int weight, | 38 int weight, |
58 SpdyStreamId parent_stream_id, | 39 SpdyStreamId parent_stream_id, |
59 bool exclusive, | 40 bool exclusive, |
60 bool fin, | 41 bool fin, |
61 const SpdyHeaderBlock& headers) = 0; | 42 const SpdyHeaderBlock& headers) = 0; |
62 | 43 |
63 // Called when a data frame header is received. | 44 // Called when a data frame header is received. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 protected: | 114 protected: |
134 virtual ~BufferedSpdyFramerVisitorInterface() {} | 115 virtual ~BufferedSpdyFramerVisitorInterface() {} |
135 | 116 |
136 private: | 117 private: |
137 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramerVisitorInterface); | 118 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramerVisitorInterface); |
138 }; | 119 }; |
139 | 120 |
140 class NET_EXPORT_PRIVATE BufferedSpdyFramer | 121 class NET_EXPORT_PRIVATE BufferedSpdyFramer |
141 : public SpdyFramerVisitorInterface { | 122 : public SpdyFramerVisitorInterface { |
142 public: | 123 public: |
143 explicit BufferedSpdyFramer(SpdyMajorVersion version); | 124 BufferedSpdyFramer(); |
144 ~BufferedSpdyFramer() override; | 125 ~BufferedSpdyFramer() override; |
145 | 126 |
146 // Sets callbacks to be called from the buffered spdy framer. A visitor must | 127 // Sets callbacks to be called from the buffered spdy framer. A visitor must |
147 // be set, or else the framer will likely crash. It is acceptable for the | 128 // be set, or else the framer will likely crash. It is acceptable for the |
148 // visitor to do nothing. If this is called multiple times, only the last | 129 // visitor to do nothing. If this is called multiple times, only the last |
149 // visitor will be used. | 130 // visitor will be used. |
150 void set_visitor(BufferedSpdyFramerVisitorInterface* visitor); | 131 void set_visitor(BufferedSpdyFramerVisitorInterface* visitor); |
151 | 132 |
152 // Set debug callbacks to be called from the framer. The debug visitor is | 133 // Set debug callbacks to be called from the framer. The debug visitor is |
153 // completely optional and need not be set in order for normal operation. | 134 // completely optional and need not be set in order for normal operation. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 const SpdyAltSvcWireFormat::AlternativeServiceVector& | 179 const SpdyAltSvcWireFormat::AlternativeServiceVector& |
199 altsvc_vector) override; | 180 altsvc_vector) override; |
200 void OnDataFrameHeader(SpdyStreamId stream_id, | 181 void OnDataFrameHeader(SpdyStreamId stream_id, |
201 size_t length, | 182 size_t length, |
202 bool fin) override; | 183 bool fin) override; |
203 void OnContinuation(SpdyStreamId stream_id, bool end) override; | 184 void OnContinuation(SpdyStreamId stream_id, bool end) override; |
204 bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override; | 185 bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override; |
205 | 186 |
206 // SpdyFramer methods. | 187 // SpdyFramer methods. |
207 size_t ProcessInput(const char* data, size_t len); | 188 size_t ProcessInput(const char* data, size_t len); |
208 SpdyMajorVersion protocol_version(); | |
209 void Reset(); | 189 void Reset(); |
210 SpdyFramer::SpdyError error_code() const; | 190 SpdyFramer::SpdyError error_code() const; |
211 SpdyFramer::SpdyState state() const; | 191 SpdyFramer::SpdyState state() const; |
212 bool MessageFullyRead(); | 192 bool MessageFullyRead(); |
213 bool HasError(); | 193 bool HasError(); |
214 SpdySerializedFrame* CreateSynStream(SpdyStreamId stream_id, | 194 SpdySerializedFrame* CreateSynStream(SpdyStreamId stream_id, |
215 SpdyStreamId associated_stream_id, | 195 SpdyStreamId associated_stream_id, |
216 SpdyPriority priority, | 196 SpdyPriority priority, |
217 SpdyControlFlags flags, | 197 SpdyControlFlags flags, |
218 SpdyHeaderBlock headers); | 198 SpdyHeaderBlock headers); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 std::unique_ptr<GoAwayFields> goaway_fields_; | 291 std::unique_ptr<GoAwayFields> goaway_fields_; |
312 | 292 |
313 std::unique_ptr<HeaderCoalescer> coalescer_; | 293 std::unique_ptr<HeaderCoalescer> coalescer_; |
314 | 294 |
315 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramer); | 295 DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramer); |
316 }; | 296 }; |
317 | 297 |
318 } // namespace net | 298 } // namespace net |
319 | 299 |
320 #endif // NET_SPDY_BUFFERED_SPDY_FRAMER_H_ | 300 #endif // NET_SPDY_BUFFERED_SPDY_FRAMER_H_ |
OLD | NEW |