summaryrefslogtreecommitdiffstats
path: root/net/flip/flip_framer.h
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-20 15:32:32 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-20 15:32:32 +0000
commit289b93d79e3e7a55553ae0c41fd48461e43e9d8e (patch)
tree6899338a89e927f6eff837d49ad39f91e84b4846 /net/flip/flip_framer.h
parent9194b3fc91953bb1472d8671d2322ac5616ee0b4 (diff)
downloadchromium_src-289b93d79e3e7a55553ae0c41fd48461e43e9d8e.zip
chromium_src-289b93d79e3e7a55553ae0c41fd48461e43e9d8e.tar.gz
chromium_src-289b93d79e3e7a55553ae0c41fd48461e43e9d8e.tar.bz2
Fixup the flip_framer eof-handling semantics now that we have
the FIN bit in place. The FlipFrameVisitor will always inject a zero-length data packet to the Visitor as a signal that the data stream is complete. Even if the FIN packet was set on a SYN_REPLY (e.g. there are no data packets), the FlipFramer will simulate a zero-length read to the caller. Likewise, zero-length reads are never sent to the visitor unless the FIN packet has been received. This means that the FlipFramer must swallow zero-length data packets. Also merged in changes from server. BUG=none TEST=flip_framer_test.cc Review URL: http://codereview.chromium.org/294015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/flip/flip_framer.h')
-rw-r--r--net/flip/flip_framer.h56
1 files changed, 41 insertions, 15 deletions
diff --git a/net/flip/flip_framer.h b/net/flip/flip_framer.h
index 5275017..8f89c30 100644
--- a/net/flip/flip_framer.h
+++ b/net/flip/flip_framer.h
@@ -29,6 +29,7 @@ namespace flip {
class FlipFramer;
class FlipFramerTest;
+class TestFlipVisitor;
// A datastructure for holding a set of headers from either a
// SYN_STREAM or SYN_REPLY frame.
@@ -48,6 +49,11 @@ class FlipFramerVisitorInterface {
virtual void OnControl(const FlipControlFrame* frame) = 0;
// Called when data is received.
+ // |stream_id| The stream receiving data.
+ // |data| A buffer containing the data received.
+ // |len| The length of the data buffer.
+ // When the other side has finished sending data on this stream,
+ // this method will be called with a zero-length buffer.
virtual void OnStreamFrameData(flip::FlipStreamId stream_id,
const char* data,
size_t len) = 0;
@@ -120,24 +126,44 @@ class FlipFramer {
// Returns true if successfully parsed, false otherwise.
bool ParseHeaderBlock(const FlipFrame* frame, FlipHeaderBlock* block);
- // Frame creation utilities
- // Create a FlipSynStreamControlFrame. The resulting frame will be
- // compressed if |compressed| is true.
- FlipSynStreamControlFrame* CreateSynStream(int stream_id, int priority,
- bool compress,
+ // Create a FlipSynStreamControlFrame.
+ // |stream_id| is the stream for this frame.
+ // |priority| is the priority (0-3) for this frame.
+ // |flags| is the flags to use with the data.
+ // To mark this frame as the last frame, enable CONTROL_FLAG_FIN.
+ // |compressed| specifies whether the frame should be compressed.
+ // |headers| is the header block to include in the frame.
+ FlipSynStreamControlFrame* CreateSynStream(FlipStreamId stream_id,
+ int priority,
+ FlipControlFlags flags,
+ bool compressed,
FlipHeaderBlock* headers);
- static FlipFinStreamControlFrame* CreateFinStream(int stream_id, int status);
- // Create a FlipSynReplyControlFrame.The resulting frame will be
- // compressed if |compressed| is true.
- FlipSynReplyControlFrame* CreateSynReply(int stream_id,
- bool compress,
+ static FlipFinStreamControlFrame* CreateFinStream(FlipStreamId stream_id,
+ int status);
+
+ // Create a FlipSynReplyControlFrame.
+ // |stream_id| is the stream for this frame.
+ // |flags| is the flags to use with the data.
+ // To mark this frame as the last frame, enable CONTROL_FLAG_FIN.
+ // |compressed| specifies whether the frame should be compressed.
+ // |headers| is the header block to include in the frame.
+ FlipSynReplyControlFrame* CreateSynReply(FlipStreamId stream_id,
+ FlipControlFlags flags,
+ bool compressed,
FlipHeaderBlock* headers);
- // Create a FlipDataFrame. The resulting frame will be
- // compressed if |compressed| is true.
- FlipDataFrame* CreateDataFrame(int stream_id, const char* data,
- int len, bool compressed);
+ // Create a data frame.
+ // |stream_id| is the stream for this frame
+ // |data| is the data to be included in the frame.
+ // |len| is the length of the data
+ // |flags| is the flags to use with the data.
+ // To create a compressed frame, enable DATA_FLAG_COMPRESSED.
+ // To mark this frame as the last data frame, enable DATA_FLAG_FIN.
+ FlipDataFrame* CreateDataFrame(FlipStreamId stream_id, const char* data,
+ uint32 len, FlipDataFlags flags);
+
+ static FlipControlFrame* CreateNopFrame();
// NOTES about frame compression.
// We want flip to compress headers across the entire session. As long as
@@ -172,9 +198,9 @@ class FlipFramer {
static const char* ErrorCodeToString(int error_code);
protected:
- FRIEND_TEST(FlipFramerTest, Basic);
FRIEND_TEST(FlipFramerTest, HeaderBlockBarfsOnOutOfOrderHeaders);
friend class net::FlipNetworkTransactionTest;
+ friend class flip::TestFlipVisitor;
// For ease of testing we can tweak compression on/off.
void set_enable_compression(bool value);