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

Unified Diff: net/spdy/spdy_buffer.h

Issue 13990005: [SPDY] Replace SpdyIOBuffer with new SpdyBuffer class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix missing include Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/net.gyp ('k') | net/spdy/spdy_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c4c5b8fee4140cb6e61466e25de59ad37176108e
--- /dev/null
+++ b/net/spdy/spdy_buffer.h
@@ -0,0 +1,66 @@
+// 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 but is not
+// ref-counted and will include a way to get notified when Consume()
+// is called.
+//
+// NOTE(akalin): This explicitly does not inherit from IOBuffer to
+// avoid the needless ref-counting and to avoid working around the
+// fact that IOBuffer member functions are not virtual.
+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 notified when Consume() is 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();
+
+ private:
+ const scoped_ptr<SpdyFrame> frame_;
+ size_t offset_;
+
+ DISALLOW_COPY_AND_ASSIGN(SpdyBuffer);
+};
+
+} // namespace net
+
+#endif // NET_SPDY_SPDY_BUFFER_H_
« no previous file with comments | « net/net.gyp ('k') | net/spdy/spdy_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698