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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months 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
« no previous file with comments | « net/quic/quic_data_reader.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 2013 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 #include <string>
16
17 #include "base/basictypes.h"
18 #include "base/strings/string_piece.h"
19 #include "net/base/iovec.h"
20 #include "net/base/net_export.h"
21 #include "net/quic/quic_ack_notifier.h"
22 #include "net/quic/quic_protocol.h"
23 #include "net/quic/quic_stream_sequencer.h"
24 #include "net/quic/reliable_quic_stream.h"
25 #include "net/spdy/spdy_framer.h"
26
27 namespace net {
28
29 namespace test {
30 class QuicDataStreamPeer;
31 class ReliableQuicStreamPeer;
32 } // namespace test
33
34 class IPEndPoint;
35 class QuicSession;
36 class SSLInfo;
37
38 // All this does right now is send data to subclasses via the sequencer.
39 class NET_EXPORT_PRIVATE QuicDataStream : public ReliableQuicStream {
40 public:
41 // Visitor receives callbacks from the stream.
42 class Visitor {
43 public:
44 Visitor() {}
45
46 // Called when the stream is closed.
47 virtual void OnClose(QuicDataStream* stream) = 0;
48
49 protected:
50 virtual ~Visitor() {}
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(Visitor);
54 };
55
56 QuicDataStream(QuicStreamId id, QuicSession* session);
57
58 ~QuicDataStream() override;
59
60 // ReliableQuicStream implementation
61 void OnClose() override;
62 uint32 ProcessRawData(const char* data, uint32 data_len) override;
63 // By default, this is the same as priority(), however it allows streams
64 // to temporarily alter effective priority. For example if a SPDY stream has
65 // compressed but not written headers it can write the headers with a higher
66 // priority.
67 QuicPriority EffectivePriority() const override;
68
69 // Overridden by subclasses to process data. The headers will be delivered
70 // via OnStreamHeaders, so only data will be delivered through this method.
71 virtual uint32 ProcessData(const char* data, uint32 data_len) = 0;
72
73 // Called by the session when decompressed headers data is received
74 // for this stream.
75 // May be called multiple times, with each call providing additional headers
76 // data until OnStreamHeadersComplete is called.
77 virtual void OnStreamHeaders(base::StringPiece headers_data);
78
79 // Called by the session when headers with a priority have been received
80 // for this stream. This method will only be called for server streams.
81 virtual void OnStreamHeadersPriority(QuicPriority priority);
82
83 // Called by the session when decompressed headers have been completely
84 // delilvered to this stream. If |fin| is true, then this stream
85 // should be closed; no more data will be sent by the peer.
86 virtual void OnStreamHeadersComplete(bool fin, size_t frame_len);
87
88 // Writes the headers contained in |header_block| to the dedicated
89 // headers stream.
90 virtual size_t WriteHeaders(
91 const SpdyHeaderBlock& header_block,
92 bool fin,
93 QuicAckNotifier::DelegateInterface* ack_notifier_delegate);
94
95 // This block of functions wraps the sequencer's functions of the same
96 // name. These methods return uncompressed data until that has
97 // been fully processed. Then they simply delegate to the sequencer.
98 virtual size_t Readv(const struct iovec* iov, size_t iov_len);
99 virtual int GetReadableRegions(iovec* iov, size_t iov_len);
100 // Returns true when all data has been read from the peer, including the fin.
101 virtual bool IsDoneReading() const;
102 virtual bool HasBytesToRead() const;
103
104 void set_visitor(Visitor* visitor) { visitor_ = visitor; }
105
106 bool headers_decompressed() const { return headers_decompressed_; }
107
108 const IPEndPoint& GetPeerAddress();
109
110 // Gets the SSL connection information.
111 bool GetSSLInfo(SSLInfo* ssl_info);
112
113 protected:
114 // Sets priority_ to priority. This should only be called before bytes are
115 // written to the server.
116 void set_priority(QuicPriority priority);
117 // This is protected because external classes should use EffectivePriority
118 // instead.
119 QuicPriority priority() const { return priority_; }
120
121 private:
122 friend class test::QuicDataStreamPeer;
123 friend class test::ReliableQuicStreamPeer;
124 friend class QuicStreamUtils;
125
126 uint32 ProcessHeaderData();
127
128 bool FinishedReadingHeaders();
129
130 Visitor* visitor_;
131 // True if the headers have been completely decompresssed.
132 bool headers_decompressed_;
133 // The priority of the stream, once parsed.
134 QuicPriority priority_;
135 // Contains a copy of the decompressed headers until they are consumed
136 // via ProcessData or Readv.
137 std::string decompressed_headers_;
138 // True if an error was encountered during decompression.
139 bool decompression_failed_;
140 // True if the priority has been read, false otherwise.
141 bool priority_parsed_;
142
143 DISALLOW_COPY_AND_ASSIGN(QuicDataStream);
144 };
145
146 } // namespace net
147
148 #endif // NET_QUIC_QUIC_DATA_STREAM_H_
OLDNEW
« no previous file with comments | « net/quic/quic_data_reader.cc ('k') | net/quic/quic_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698