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_SPDY_FRAMER_H_ | 5 #ifndef NET_SPDY_SPDY_FRAMER_H_ |
6 #define NET_SPDY_SPDY_FRAMER_H_ | 6 #define NET_SPDY_SPDY_FRAMER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // |headers| is the header block to include in the frame. | 361 // |headers| is the header block to include in the frame. |
362 SpdySynStreamControlFrame* CreateSynStream(SpdyStreamId stream_id, | 362 SpdySynStreamControlFrame* CreateSynStream(SpdyStreamId stream_id, |
363 SpdyStreamId associated_stream_id, | 363 SpdyStreamId associated_stream_id, |
364 SpdyPriority priority, | 364 SpdyPriority priority, |
365 uint8 credential_slot, | 365 uint8 credential_slot, |
366 SpdyControlFlags flags, | 366 SpdyControlFlags flags, |
367 bool compressed, | 367 bool compressed, |
368 const SpdyHeaderBlock* headers); | 368 const SpdyHeaderBlock* headers); |
369 SpdySerializedFrame* SerializeSynStream(const SpdySynStreamIR& syn_stream); | 369 SpdySerializedFrame* SerializeSynStream(const SpdySynStreamIR& syn_stream); |
370 | 370 |
371 // Create a SpdySynReplyControlFrame. | 371 // Create a SYN_REPLY SpdyFrame. |
372 // |stream_id| is the stream for this frame. | 372 // |stream_id| is the stream for this frame. |
373 // |flags| is the flags to use with the data. | 373 // |flags| is the flags to use with the data. |
374 // To mark this frame as the last frame, enable CONTROL_FLAG_FIN. | 374 // To mark this frame as the last frame, enable CONTROL_FLAG_FIN. |
375 // |compressed| specifies whether the frame should be compressed. | 375 // |compressed| specifies whether the frame should be compressed. |
376 // |headers| is the header block to include in the frame. | 376 // |headers| is the header block to include in the frame. |
377 SpdySynReplyControlFrame* CreateSynReply(SpdyStreamId stream_id, | 377 SpdyFrame* CreateSynReply(SpdyStreamId stream_id, |
378 SpdyControlFlags flags, | 378 SpdyControlFlags flags, |
379 bool compressed, | 379 bool compressed, |
380 const SpdyHeaderBlock* headers); | 380 const SpdyHeaderBlock* headers); |
381 SpdySerializedFrame* SerializeSynReply(const SpdySynReplyIR& syn_reply); | 381 SpdySerializedFrame* SerializeSynReply(const SpdySynReplyIR& syn_reply); |
382 | 382 |
383 SpdyRstStreamControlFrame* CreateRstStream(SpdyStreamId stream_id, | 383 SpdyRstStreamControlFrame* CreateRstStream(SpdyStreamId stream_id, |
384 SpdyRstStreamStatus status) const; | 384 SpdyRstStreamStatus status) const; |
385 SpdySerializedFrame* SerializeRstStream( | 385 SpdySerializedFrame* SerializeRstStream( |
386 const SpdyRstStreamIR& rst_stream) const; | 386 const SpdyRstStreamIR& rst_stream) const; |
387 | 387 |
388 // Creates an instance of SpdySettingsControlFrame. The SETTINGS frame is | 388 // Creates an instance of SpdySettingsControlFrame. The SETTINGS frame is |
389 // used to communicate name/value pairs relevant to the communication channel. | 389 // used to communicate name/value pairs relevant to the communication channel. |
390 SpdySettingsControlFrame* CreateSettings(const SettingsMap& values) const; | 390 SpdySettingsControlFrame* CreateSettings(const SettingsMap& values) const; |
391 SpdySerializedFrame* SerializeSettings(const SpdySettingsIR& settings) const; | 391 SpdySerializedFrame* SerializeSettings(const SpdySettingsIR& settings) const; |
392 | 392 |
393 // Creates an instance of SpdyPingControlFrame. The unique_id is used to | 393 // Creates an instance of SpdyPingControlFrame. The unique_id is used to |
394 // identify the ping request/response. | 394 // identify the ping request/response. |
395 SpdyPingControlFrame* CreatePingFrame(uint32 unique_id) const; | 395 SpdyPingControlFrame* CreatePingFrame(uint32 unique_id) const; |
396 SpdySerializedFrame* SerializePing(const SpdyPingIR& ping) const; | 396 SpdySerializedFrame* SerializePing(const SpdyPingIR& ping) const; |
397 | 397 |
398 // Creates an instance of SpdyGoAwayControlFrame. The GOAWAY frame is used | 398 // Creates and serializes a GOAWAY frame. The GOAWAY frame is used |
399 // prior to the shutting down of the TCP connection, and includes the | 399 // prior to the shutting down of the TCP connection, and includes the |
400 // stream_id of the last stream the sender of the frame is willing to process | 400 // stream_id of the last stream the sender of the frame is willing to process |
401 // to completion. | 401 // to completion. |
402 SpdyGoAwayControlFrame* CreateGoAway(SpdyStreamId last_accepted_stream_id, | 402 SpdyFrame* CreateGoAway(SpdyStreamId last_accepted_stream_id, |
403 SpdyGoAwayStatus status) const; | 403 SpdyGoAwayStatus status) const; |
404 SpdySerializedFrame* SerializeGoAway(const SpdyGoAwayIR& goaway) const; | 404 SpdySerializedFrame* SerializeGoAway(const SpdyGoAwayIR& goaway) const; |
405 | 405 |
406 // Creates an instance of SpdyHeadersControlFrame. The HEADERS frame is used | 406 // Creates an instance of SpdyHeadersControlFrame. The HEADERS frame is used |
407 // for sending additional headers outside of a SYN_STREAM/SYN_REPLY. The | 407 // for sending additional headers outside of a SYN_STREAM/SYN_REPLY. The |
408 // arguments are the same as for CreateSynReply. | 408 // arguments are the same as for CreateSynReply. |
409 SpdyHeadersControlFrame* CreateHeaders(SpdyStreamId stream_id, | 409 SpdyHeadersControlFrame* CreateHeaders(SpdyStreamId stream_id, |
410 SpdyControlFlags flags, | 410 SpdyControlFlags flags, |
411 bool compressed, | 411 bool compressed, |
412 const SpdyHeaderBlock* headers); | 412 const SpdyHeaderBlock* headers); |
413 SpdySerializedFrame* SerializeHeaders(const SpdyHeadersIR& headers); | 413 SpdySerializedFrame* SerializeHeaders(const SpdyHeadersIR& headers); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 void WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, | 584 void WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, |
585 z_stream* out) const; | 585 z_stream* out) const; |
586 | 586 |
587 void SerializeNameValueBlock( | 587 void SerializeNameValueBlock( |
588 SpdyFrameBuilder* builder, | 588 SpdyFrameBuilder* builder, |
589 const SpdyFrameWithNameValueBlockIR& frame) const; | 589 const SpdyFrameWithNameValueBlockIR& frame) const; |
590 | 590 |
591 // Set the error code and moves the framer into the error state. | 591 // Set the error code and moves the framer into the error state. |
592 void set_error(SpdyError error); | 592 void set_error(SpdyError error); |
593 | 593 |
| 594 size_t GoAwaySize() const; |
| 595 |
594 // Given a frame, breakdown the variable payload length, the static header | 596 // Given a frame, breakdown the variable payload length, the static header |
595 // header length, and variable payload pointer. | 597 // header length, and variable payload pointer. |
596 bool GetFrameBoundaries(const SpdyFrame& frame, int* payload_length, | 598 bool GetFrameBoundaries(const SpdyFrame& frame, int* payload_length, |
597 int* header_length, const char** payload) const; | 599 int* header_length, const char** payload) const; |
598 | 600 |
599 // Returns a new SpdyControlFrame with the compressed payload of |frame|. | 601 // Returns a new SpdyControlFrame with the compressed payload of |frame|. |
600 SpdyControlFrame* CompressControlFrame(const SpdyControlFrame& frame, | 602 SpdyControlFrame* CompressControlFrame(const SpdyControlFrame& frame, |
601 const SpdyHeaderBlock* headers); | 603 const SpdyHeaderBlock* headers); |
602 | 604 |
603 // The size of the control frame buffer. | 605 // The size of the control frame buffer. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // starts with HTTP. If it does, we likely have an HTTP response. This | 664 // starts with HTTP. If it does, we likely have an HTTP response. This |
663 // isn't guaranteed though: we could have gotten a settings frame and then | 665 // isn't guaranteed though: we could have gotten a settings frame and then |
664 // corrupt data that just looks like HTTP, but deterministic checking requires | 666 // corrupt data that just looks like HTTP, but deterministic checking requires |
665 // a lot more state. | 667 // a lot more state. |
666 bool probable_http_response_; | 668 bool probable_http_response_; |
667 }; | 669 }; |
668 | 670 |
669 } // namespace net | 671 } // namespace net |
670 | 672 |
671 #endif // NET_SPDY_SPDY_FRAMER_H_ | 673 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |