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

Unified Diff: net/spdy/spdy_buffer.h

Issue 14311002: [SPDY] Avoid leaking bytes from the session flow control receive window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 | « no previous file | 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
index c4c5b8fee4140cb6e61466e25de59ad37176108e..4d04184d7ff7af8169b3700a2d9ea4d14f2b879c 100644
--- a/net/spdy/spdy_buffer.h
+++ b/net/spdy/spdy_buffer.h
@@ -6,8 +6,10 @@
#define NET_SPDY_SPDY_BUFFER_H_
#include <cstddef>
+#include <vector>
#include "base/basictypes.h"
+#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
#include "net/base/net_export.h"
@@ -26,6 +28,10 @@ class SpdyFrame;
// fact that IOBuffer member functions are not virtual.
class NET_EXPORT_PRIVATE SpdyBuffer {
public:
+ // A Callback that gets called whenever Consume() is called with the
+ // number of bytes consumed.
+ typedef base::Callback<void(size_t)> ConsumeCallback;
+
// Construct with the data in the given frame. Assumes that data is
// owned by |frame| or outlives it.
explicit SpdyBuffer(scoped_ptr<SpdyFrame> frame);
@@ -42,10 +48,15 @@ class NET_EXPORT_PRIVATE SpdyBuffer {
// Returns the number of remaining (unconsumed) bytes.
size_t GetRemainingSize() const;
+ // Add a callback which is called whenever Consume() is called. Used
+ // mainly to update flow control windows. The ConsumeCallback should
+ // not do anything complicated; ideally it should only update a
+ // counter. In particular, it must *not* cause the SpdyBuffer itself
+ // to be destroyed.
+ void AddConsumeCallback(const ConsumeCallback& consume_callback);
+
// 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
@@ -56,6 +67,7 @@ class NET_EXPORT_PRIVATE SpdyBuffer {
private:
const scoped_ptr<SpdyFrame> frame_;
+ std::vector<ConsumeCallback> consume_callbacks_;
size_t offset_;
DISALLOW_COPY_AND_ASSIGN(SpdyBuffer);
« no previous file with comments | « no previous file | net/spdy/spdy_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698