Index: net/spdy/spdy_buffer.h |
diff --git a/net/spdy/spdy_buffer.h b/net/spdy/spdy_buffer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0ccd25199afce6c09c9e6e792443f92e4fd5aabf |
--- /dev/null |
+++ b/net/spdy/spdy_buffer.h |
@@ -0,0 +1,61 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_SPDY_SPDY_BUFFER_H_ |
+#define NET_SPDY_SPDY_BUFFER_H_ |
+ |
+#include <cstddef> |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "net/base/net_export.h" |
+ |
+namespace net { |
+ |
+class IOBuffer; |
+class SpdyFrame; |
+ |
+// SpdyBuffer is a class to hold data read from or to be written to a |
+// 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.
|
+class NET_EXPORT_PRIVATE SpdyBuffer { |
+ public: |
+ // Construct with the data in the given frame. Assumes that data is |
+ // owned by |frame| or outlives it. |
+ explicit SpdyBuffer(scoped_ptr<SpdyFrame> frame); |
+ |
+ // Construct with a copy of the given raw data. |data| must be |
+ // non-NULL and |size| must be non-zero. |
+ SpdyBuffer(const char* data, size_t size); |
+ |
+ ~SpdyBuffer(); |
+ |
+ // Returns the remaining (unconsumed) data. |
+ const char* GetRemainingData() const; |
+ |
+ // Returns the number of remaining (unconsumed) bytes. |
+ size_t GetRemainingSize() const; |
+ |
+ // Consume the given number of bytes, which must be positive but not |
+ // greater than GetRemainingSize(). |
+ // |
+ // 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!
|
+ // called. |
+ void Consume(size_t consume_size); |
+ |
+ // Returns an IOBuffer pointing to the data starting at |
+ // GetRemainingData(). Use with care; the returned IOBuffer must not |
+ // be used past the lifetime of this object, and it is not updated |
+ // when Consume() is called. |
+ 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
|
+ |
+ private: |
+ const scoped_ptr<SpdyFrame> frame_; |
+ size_t offset_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SpdyBuffer); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_SPDY_SPDY_BUFFER_H_ |