OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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 #ifndef NET_SPDY_SPDY_BUFFER_H_ | |
6 #define NET_SPDY_SPDY_BUFFER_H_ | |
7 | |
8 #include <cstddef> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "net/base/net_export.h" | |
13 | |
14 namespace net { | |
15 | |
16 class IOBuffer; | |
17 class SpdyFrame; | |
18 | |
19 // SpdyBuffer is a class to hold data read from or to be written to a | |
20 // SPDY connection. It is similar to a DrainableIOBuffer. | |
Ryan Hamilton
2013/04/16 18:44:25
nit: Can you add a comment which explains why it i
akalin
2013/04/16 23:01:46
Done.
| |
21 class NET_EXPORT_PRIVATE SpdyBuffer { | |
22 public: | |
23 // Construct with the data in the given frame. Assumes that data is | |
24 // owned by |frame| or outlives it. | |
25 explicit SpdyBuffer(scoped_ptr<SpdyFrame> frame); | |
26 | |
27 // Construct with a copy of the given raw data. |data| must be | |
28 // non-NULL and |size| must be non-zero. | |
29 SpdyBuffer(const char* data, size_t size); | |
30 | |
31 ~SpdyBuffer(); | |
32 | |
33 // Returns the remaining (unconsumed) data. | |
34 const char* GetRemainingData() const; | |
35 | |
36 // Returns the number of remaining (unconsumed) bytes. | |
37 size_t GetRemainingSize() const; | |
38 | |
39 // Consume the given number of bytes, which must be positive but not | |
40 // greater than GetRemainingSize(). | |
41 // | |
42 // TODO(akalin): Add a way to get called back when Consume() is | |
Ryan Hamilton
2013/04/16 18:44:25
Who should be called back when Consume is called?
akalin
2013/04/16 23:01:46
The session and the stream. CL coming!
| |
43 // called. | |
44 void Consume(size_t consume_size); | |
45 | |
46 // Returns an IOBuffer pointing to the data starting at | |
47 // GetRemainingData(). Use with care; the returned IOBuffer must not | |
48 // be used past the lifetime of this object, and it is not updated | |
49 // when Consume() is called. | |
50 IOBuffer* GetIOBufferForRemainingData(); | |
Ryan Hamilton
2013/04/16 18:44:25
Interesting. IOBuffers are refcounted, right? It
akalin
2013/04/16 23:01:46
It is, but it's unavoidable. :/ It's only used in
Ryan Hamilton
2013/04/16 23:34:11
Sounds good. Can you add a comment in SpdySession
| |
51 | |
52 private: | |
53 const scoped_ptr<SpdyFrame> frame_; | |
54 size_t offset_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(SpdyBuffer); | |
57 }; | |
58 | |
59 } // namespace net | |
60 | |
61 #endif // NET_SPDY_SPDY_BUFFER_H_ | |
OLD | NEW |