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

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

Issue 15555003: [SPDY] Remove SpdyStream::Delegate::OnSendBody()'s return value (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove return value Created 7 years, 7 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
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> 7 #include <cstddef>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/completion_callback.h" 10 #include "net/base/completion_callback.h"
11 #include "net/spdy/spdy_stream.h" 11 #include "net/spdy/spdy_stream.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 namespace test { 16 namespace test {
17 17
18 ClosingDelegate::ClosingDelegate( 18 ClosingDelegate::ClosingDelegate(
19 const base::WeakPtr<SpdyStream>& stream) : stream_(stream) {} 19 const base::WeakPtr<SpdyStream>& stream) : stream_(stream) {}
20 20
21 ClosingDelegate::~ClosingDelegate() {} 21 ClosingDelegate::~ClosingDelegate() {}
22 22
23 SpdySendStatus ClosingDelegate::OnSendHeadersComplete() { 23 SpdySendStatus ClosingDelegate::OnSendHeadersComplete() {
24 return NO_MORE_DATA_TO_SEND; 24 return NO_MORE_DATA_TO_SEND;
25 } 25 }
26 26
27 int ClosingDelegate::OnSendBody() { 27 void ClosingDelegate::OnSendBody() {
28 return OK; 28 ADD_FAILURE() << "OnSendBody should not be called";
29 } 29 }
30 30
31 SpdySendStatus ClosingDelegate::OnSendBodyComplete(size_t /*bytes_sent*/) { 31 SpdySendStatus ClosingDelegate::OnSendBodyComplete(size_t /*bytes_sent*/) {
32 return NO_MORE_DATA_TO_SEND; 32 return NO_MORE_DATA_TO_SEND;
33 } 33 }
34 34
35 int ClosingDelegate::OnResponseReceived(const SpdyHeaderBlock& response, 35 int ClosingDelegate::OnResponseReceived(const SpdyHeaderBlock& response,
36 base::Time response_time, 36 base::Time response_time,
37 int status) { 37 int status) {
38 return OK; 38 return OK;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return (it == response_.end()) ? std::string() : it->second; 124 return (it == response_.end()) ? std::string() : it->second;
125 } 125 }
126 126
127 StreamDelegateDoNothing::StreamDelegateDoNothing( 127 StreamDelegateDoNothing::StreamDelegateDoNothing(
128 const base::WeakPtr<SpdyStream>& stream) 128 const base::WeakPtr<SpdyStream>& stream)
129 : StreamDelegateBase(stream) {} 129 : StreamDelegateBase(stream) {}
130 130
131 StreamDelegateDoNothing::~StreamDelegateDoNothing() { 131 StreamDelegateDoNothing::~StreamDelegateDoNothing() {
132 } 132 }
133 133
134 int StreamDelegateDoNothing::OnSendBody() { 134 void StreamDelegateDoNothing::OnSendBody() {
135 return OK; 135 ADD_FAILURE() << "OnSendBody should not be called";
136 } 136 }
137
137 SpdySendStatus StreamDelegateDoNothing::OnSendBodyComplete( 138 SpdySendStatus StreamDelegateDoNothing::OnSendBodyComplete(
138 size_t /*bytes_sent*/) { 139 size_t /*bytes_sent*/) {
139 return NO_MORE_DATA_TO_SEND; 140 return NO_MORE_DATA_TO_SEND;
140 } 141 }
141 142
142 StreamDelegateSendImmediate::StreamDelegateSendImmediate( 143 StreamDelegateSendImmediate::StreamDelegateSendImmediate(
143 const base::WeakPtr<SpdyStream>& stream, 144 const base::WeakPtr<SpdyStream>& stream,
144 scoped_ptr<SpdyHeaderBlock> headers, 145 scoped_ptr<SpdyHeaderBlock> headers,
145 base::StringPiece data) 146 base::StringPiece data)
146 : StreamDelegateBase(stream), 147 : StreamDelegateBase(stream),
147 headers_(headers.Pass()), 148 headers_(headers.Pass()),
148 data_(data) {} 149 data_(data) {}
149 150
150 StreamDelegateSendImmediate::~StreamDelegateSendImmediate() { 151 StreamDelegateSendImmediate::~StreamDelegateSendImmediate() {
151 } 152 }
152 153
153 int StreamDelegateSendImmediate::OnSendBody() { 154 void StreamDelegateSendImmediate::OnSendBody() {
154 ADD_FAILURE() << "OnSendBody should not be called"; 155 ADD_FAILURE() << "OnSendBody should not be called";
155 return ERR_UNEXPECTED;
156 } 156 }
157
157 SpdySendStatus StreamDelegateSendImmediate::OnSendBodyComplete( 158 SpdySendStatus StreamDelegateSendImmediate::OnSendBodyComplete(
158 size_t /*bytes_sent*/) { 159 size_t /*bytes_sent*/) {
159 ADD_FAILURE() << "OnSendBodyComplete should not be called"; 160 ADD_FAILURE() << "OnSendBodyComplete should not be called";
160 return NO_MORE_DATA_TO_SEND; 161 return NO_MORE_DATA_TO_SEND;
161 } 162 }
162 163
163 int StreamDelegateSendImmediate::OnResponseReceived( 164 int StreamDelegateSendImmediate::OnResponseReceived(
164 const SpdyHeaderBlock& response, 165 const SpdyHeaderBlock& response,
165 base::Time response_time, 166 base::Time response_time,
166 int status) { 167 int status) {
(...skipping 13 matching lines...) Expand all
180 const base::WeakPtr<SpdyStream>& stream, 181 const base::WeakPtr<SpdyStream>& stream,
181 base::StringPiece data) 182 base::StringPiece data)
182 : StreamDelegateBase(stream), 183 : StreamDelegateBase(stream),
183 buf_(new DrainableIOBuffer(new StringIOBuffer(data.as_string()), 184 buf_(new DrainableIOBuffer(new StringIOBuffer(data.as_string()),
184 data.size())), 185 data.size())),
185 body_data_sent_(0) {} 186 body_data_sent_(0) {}
186 187
187 StreamDelegateWithBody::~StreamDelegateWithBody() { 188 StreamDelegateWithBody::~StreamDelegateWithBody() {
188 } 189 }
189 190
190 int StreamDelegateWithBody::OnSendBody() { 191 void StreamDelegateWithBody::OnSendBody() {
191 stream()->QueueStreamData(buf_.get(), buf_->BytesRemaining(), 192 stream()->QueueStreamData(buf_.get(), buf_->BytesRemaining(),
192 DATA_FLAG_NONE); 193 DATA_FLAG_NONE);
193 return ERR_IO_PENDING;
194 } 194 }
195 195
196 SpdySendStatus StreamDelegateWithBody::OnSendBodyComplete(size_t bytes_sent) { 196 SpdySendStatus StreamDelegateWithBody::OnSendBodyComplete(size_t bytes_sent) {
197 EXPECT_GT(bytes_sent, 0u); 197 EXPECT_GT(bytes_sent, 0u);
198 198
199 buf_->DidConsume(bytes_sent); 199 buf_->DidConsume(bytes_sent);
200 body_data_sent_ += bytes_sent; 200 body_data_sent_ += bytes_sent;
201 if (buf_->BytesRemaining() > 0) { 201 if (buf_->BytesRemaining() > 0) {
202 // Go back to OnSendBody() to send the remaining data. 202 // Go back to OnSendBody() to send the remaining data.
203 return MORE_DATA_TO_SEND; 203 return MORE_DATA_TO_SEND;
204 } 204 }
205 205
206 return NO_MORE_DATA_TO_SEND; 206 return NO_MORE_DATA_TO_SEND;
207 } 207 }
208 208
209 } // namespace test 209 } // namespace test
210 210
211 } // namespace net 211 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698