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

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

Issue 15701009: [SPDY] Add a SpdyStreamType enum and use it for SpdyStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK -> DCHECK 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::OnSendRequestHeadersComplete() { 23 void ClosingDelegate::OnSendRequestHeadersComplete() {}
24 return NO_MORE_DATA_TO_SEND;
25 }
26 24
27 void ClosingDelegate::OnSendBody() { 25 void ClosingDelegate::OnSendBody() {
28 ADD_FAILURE() << "OnSendBody should not be called"; 26 ADD_FAILURE() << "OnSendBody should not be called";
29 } 27 }
30 28
31 void ClosingDelegate::OnSendBodyComplete() {} 29 void ClosingDelegate::OnSendBodyComplete() {}
32 30
33 int ClosingDelegate::OnResponseReceived(const SpdyHeaderBlock& response, 31 int ClosingDelegate::OnResponseReceived(const SpdyHeaderBlock& response,
34 base::Time response_time, 32 base::Time response_time,
35 int status) { 33 int status) {
(...skipping 15 matching lines...) Expand all
51 StreamDelegateBase::StreamDelegateBase( 49 StreamDelegateBase::StreamDelegateBase(
52 const base::WeakPtr<SpdyStream>& stream) 50 const base::WeakPtr<SpdyStream>& stream)
53 : stream_(stream), 51 : stream_(stream),
54 stream_id_(0), 52 stream_id_(0),
55 send_headers_completed_(false) { 53 send_headers_completed_(false) {
56 } 54 }
57 55
58 StreamDelegateBase::~StreamDelegateBase() { 56 StreamDelegateBase::~StreamDelegateBase() {
59 } 57 }
60 58
61 SpdySendStatus StreamDelegateBase::OnSendRequestHeadersComplete() { 59 void StreamDelegateBase::OnSendRequestHeadersComplete() {
62 stream_id_ = stream_->stream_id(); 60 stream_id_ = stream_->stream_id();
63 EXPECT_NE(stream_id_, 0u); 61 EXPECT_NE(stream_id_, 0u);
64 send_headers_completed_ = true; 62 send_headers_completed_ = true;
65 return NO_MORE_DATA_TO_SEND;
66 } 63 }
67 64
68 int StreamDelegateBase::OnResponseReceived(const SpdyHeaderBlock& response, 65 int StreamDelegateBase::OnResponseReceived(const SpdyHeaderBlock& response,
69 base::Time response_time, 66 base::Time response_time,
70 int status) { 67 int status) {
71 EXPECT_TRUE(send_headers_completed_); 68 EXPECT_TRUE(send_headers_completed_);
72 response_ = response; 69 response_ = response;
73 return status; 70 return status;
74 } 71 }
75 72
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 154
158 StreamDelegateWithBody::StreamDelegateWithBody( 155 StreamDelegateWithBody::StreamDelegateWithBody(
159 const base::WeakPtr<SpdyStream>& stream, 156 const base::WeakPtr<SpdyStream>& stream,
160 base::StringPiece data) 157 base::StringPiece data)
161 : StreamDelegateBase(stream), 158 : StreamDelegateBase(stream),
162 buf_(new StringIOBuffer(data.as_string())) {} 159 buf_(new StringIOBuffer(data.as_string())) {}
163 160
164 StreamDelegateWithBody::~StreamDelegateWithBody() { 161 StreamDelegateWithBody::~StreamDelegateWithBody() {
165 } 162 }
166 163
167 SpdySendStatus StreamDelegateWithBody::OnSendRequestHeadersComplete() {
168 StreamDelegateBase::OnSendRequestHeadersComplete();
169 return MORE_DATA_TO_SEND;
170 }
171
172 void StreamDelegateWithBody::OnSendBody() { 164 void StreamDelegateWithBody::OnSendBody() {
173 stream()->SendStreamData(buf_.get(), buf_->size(), NO_MORE_DATA_TO_SEND); 165 stream()->SendStreamData(buf_.get(), buf_->size(), NO_MORE_DATA_TO_SEND);
174 } 166 }
175 167
176 void StreamDelegateWithBody::OnSendBodyComplete() {} 168 void StreamDelegateWithBody::OnSendBodyComplete() {}
177 169
178 } // namespace test 170 } // namespace test
179 171
180 } // namespace net 172 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698