Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: net/quic/quic_data_stream.h

Issue 100173005: Break out the basic reliable QUIC stream functionality from the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_crypto_stream_test.cc ('k') | net/quic/quic_data_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // The base class for streams which deliver data to/from an application.
6 // In each direction, the data on such a stream first contains compressed
7 // headers then body data.
8
9 #ifndef NET_QUIC_QUIC_DATA_STREAM_H_
10 #define NET_QUIC_QUIC_DATA_STREAM_H_
11
12 #include <sys/types.h>
13
14 #include <list>
15
16 #include "base/strings/string_piece.h"
17 #include "net/base/iovec.h"
18 #include "net/base/net_export.h"
19 #include "net/quic/quic_ack_notifier.h"
20 #include "net/quic/quic_spdy_compressor.h"
21 #include "net/quic/quic_spdy_decompressor.h"
22 #include "net/quic/quic_stream_sequencer.h"
23 #include "net/quic/reliable_quic_stream.h"
24
25 namespace net {
26
27 namespace test {
28 class QuicDataStreamPeer;
29 class ReliableQuicStreamPeer;
30 } // namespace test
31
32 class IPEndPoint;
33 class QuicSession;
34 class SSLInfo;
35
36 // All this does right now is send data to subclasses via the sequencer.
37 class NET_EXPORT_PRIVATE QuicDataStream : public ReliableQuicStream,
38 public QuicSpdyDecompressor::Visitor {
39 public:
40 // Visitor receives callbacks from the stream.
41 class Visitor {
42 public:
43 Visitor() {}
44
45 // Called when the stream is closed.
46 virtual void OnClose(QuicDataStream* stream) = 0;
47
48 protected:
49 virtual ~Visitor() {}
50
51 private:
52 DISALLOW_COPY_AND_ASSIGN(Visitor);
53 };
54
55 QuicDataStream(QuicStreamId id, QuicSession* session);
56
57 virtual ~QuicDataStream();
58
59 // ReliableQuicStream implementation
60 virtual void OnClose() OVERRIDE;
61 // By default, this is the same as priority(), however it allows streams
62 // to temporarily alter effective priority. For example if a SPDY stream has
63 // compressed but not written headers it can write the headers with a higher
64 // priority.
65 virtual QuicPriority EffectivePriority() const OVERRIDE;
66 virtual uint32 ProcessRawData(const char* data, uint32 data_len) OVERRIDE;
67
68 // QuicSpdyDecompressor::Visitor implementation.
69 virtual bool OnDecompressedData(base::StringPiece data) OVERRIDE;
70 virtual void OnDecompressionError() OVERRIDE;
71
72 virtual uint32 ProcessData(const char* data, uint32 data_len) = 0;
73
74 // This block of functions wraps the sequencer's functions of the same
75 // name. These methods return uncompressed data until that has
76 // been fully processed. Then they simply delegate to the sequencer.
77 virtual size_t Readv(const struct iovec* iov, size_t iov_len);
78 virtual int GetReadableRegions(iovec* iov, size_t iov_len);
79 // Returns true when all data has been read from the peer, including the fin.
80 virtual bool IsDoneReading() const;
81 virtual bool HasBytesToRead() const;
82
83 // Called by the session when a decompression blocked stream
84 // becomes unblocked.
85 virtual void OnDecompressorAvailable();
86
87 void set_visitor(Visitor* visitor) { visitor_ = visitor; }
88
89 bool headers_decompressed() const { return headers_decompressed_; }
90
91 const IPEndPoint& GetPeerAddress();
92
93 QuicSpdyCompressor* compressor();
94
95 // Gets the SSL connection information.
96 bool GetSSLInfo(SSLInfo* ssl_info);
97
98 protected:
99 // Sets priority_ to priority. This should only be called before bytes are
100 // written to the server.
101 void set_priority(QuicPriority priority);
102 // This is protected because external classes should use EffectivePriority
103 // instead.
104 QuicPriority priority() const { return priority_; }
105
106 private:
107 friend class test::QuicDataStreamPeer;
108 friend class test::ReliableQuicStreamPeer;
109 friend class QuicStreamUtils;
110
111 uint32 ProcessHeaderData();
112
113 uint32 StripPriorityAndHeaderId(const char* data, uint32 data_len);
114
115 bool FinishedReadingHeaders();
116
117 Visitor* visitor_;
118 // True if the headers have been completely decompresssed.
119 bool headers_decompressed_;
120 // The priority of the stream, once parsed.
121 QuicPriority priority_;
122 // ID of the header block sent by the peer, once parsed.
123 QuicHeaderId headers_id_;
124 // Buffer into which we write bytes from priority_ and headers_id_
125 // until each is fully parsed.
126 string headers_id_and_priority_buffer_;
127 // Contains a copy of the decompressed headers until they are consumed
128 // via ProcessData or Readv.
129 string decompressed_headers_;
130 // True if an error was encountered during decompression.
131 bool decompression_failed_;
132 // True if the priority has been read, false otherwise.
133 bool priority_parsed_;
134
135 DISALLOW_COPY_AND_ASSIGN(QuicDataStream);
136 };
137
138 } // namespace net
139
140 #endif // NET_QUIC_QUIC_DATA_STREAM_H_
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_stream_test.cc ('k') | net/quic/quic_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698