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

Side by Side Diff: net/spdy/spdy_stream_test_util.cc

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_stream_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_stream_test_util.h" 5 #include "net/spdy/spdy_stream_test_util.h"
6 6
7 #include <cstddef>
8
9 #include "base/stl_util.h"
7 #include "net/base/completion_callback.h" 10 #include "net/base/completion_callback.h"
8 #include "net/spdy/spdy_stream.h" 11 #include "net/spdy/spdy_stream.h"
9 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
10 13
11 namespace net { 14 namespace net {
12 15
13 namespace test { 16 namespace test {
14 17
15 ClosingDelegate::ClosingDelegate( 18 ClosingDelegate::ClosingDelegate(
16 const scoped_refptr<SpdyStream>& stream) : stream_(stream) {} 19 const scoped_refptr<SpdyStream>& stream) : stream_(stream) {}
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EXPECT_TRUE(send_headers_completed_); 74 EXPECT_TRUE(send_headers_completed_);
72 response_ = response; 75 response_ = response;
73 return status; 76 return status;
74 } 77 }
75 78
76 void StreamDelegateBase::OnHeadersSent() { 79 void StreamDelegateBase::OnHeadersSent() {
77 headers_sent_++; 80 headers_sent_++;
78 } 81 }
79 82
80 int StreamDelegateBase::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { 83 int StreamDelegateBase::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {
81 if (buffer) { 84 if (buffer)
82 received_data_ += std::string(buffer->GetRemainingData(), 85 received_data_queue_.Enqueue(buffer.Pass());
83 buffer->GetRemainingSize());
84 }
85 return OK; 86 return OK;
86 } 87 }
87 88
88 void StreamDelegateBase::OnDataSent(size_t bytes_sent) { 89 void StreamDelegateBase::OnDataSent(size_t bytes_sent) {
89 data_sent_ += bytes_sent; 90 data_sent_ += bytes_sent;
90 } 91 }
91 92
92 void StreamDelegateBase::OnClose(int status) { 93 void StreamDelegateBase::OnClose(int status) {
93 if (!stream_) 94 if (!stream_)
94 return; 95 return;
95 stream_ = NULL; 96 stream_ = NULL;
96 callback_.callback().Run(status); 97 callback_.callback().Run(status);
97 } 98 }
98 99
99 int StreamDelegateBase::WaitForClose() { 100 int StreamDelegateBase::WaitForClose() {
100 int result = callback_.WaitForResult(); 101 int result = callback_.WaitForResult();
101 EXPECT_TRUE(!stream_.get()); 102 EXPECT_TRUE(!stream_.get());
102 return result; 103 return result;
103 } 104 }
104 105
106 std::string StreamDelegateBase::TakeReceivedData() {
107 size_t len = received_data_queue_.GetTotalSize();
108 std::string received_data(len, '\0');
109 if (len > 0) {
110 EXPECT_EQ(
111 len,
112 received_data_queue_.Dequeue(string_as_array(&received_data), len));
113 }
114 return received_data;
115 }
116
105 std::string StreamDelegateBase::GetResponseHeaderValue( 117 std::string StreamDelegateBase::GetResponseHeaderValue(
106 const std::string& name) const { 118 const std::string& name) const {
107 SpdyHeaderBlock::const_iterator it = response_.find(name); 119 SpdyHeaderBlock::const_iterator it = response_.find(name);
108 return (it == response_.end()) ? std::string() : it->second; 120 return (it == response_.end()) ? std::string() : it->second;
109 } 121 }
110 122
111 StreamDelegateSendImmediate::StreamDelegateSendImmediate( 123 StreamDelegateSendImmediate::StreamDelegateSendImmediate(
112 const scoped_refptr<SpdyStream>& stream, 124 const scoped_refptr<SpdyStream>& stream,
113 scoped_ptr<SpdyHeaderBlock> headers, 125 scoped_ptr<SpdyHeaderBlock> headers,
114 base::StringPiece data) 126 base::StringPiece data)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // Go back to OnSendBody() to send the remaining data. 183 // Go back to OnSendBody() to send the remaining data.
172 return MORE_DATA_TO_SEND; 184 return MORE_DATA_TO_SEND;
173 } 185 }
174 186
175 return NO_MORE_DATA_TO_SEND; 187 return NO_MORE_DATA_TO_SEND;
176 } 188 }
177 189
178 } // namespace test 190 } // namespace test
179 191
180 } // namespace net 192 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698