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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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(const base::WeakPtr<SpdyStream>& stream)
19 const base::WeakPtr<SpdyStream>& stream) : stream_(stream) { 19 : stream_(stream) {
20 DCHECK(stream_); 20 DCHECK(stream_);
21 } 21 }
22 22
23 ClosingDelegate::~ClosingDelegate() {} 23 ClosingDelegate::~ClosingDelegate() {
24 }
24 25
25 void ClosingDelegate::OnRequestHeadersSent() {} 26 void ClosingDelegate::OnRequestHeadersSent() {
27 }
26 28
27 SpdyResponseHeadersStatus ClosingDelegate::OnResponseHeadersUpdated( 29 SpdyResponseHeadersStatus ClosingDelegate::OnResponseHeadersUpdated(
28 const SpdyHeaderBlock& response_headers) { 30 const SpdyHeaderBlock& response_headers) {
29 return RESPONSE_HEADERS_ARE_COMPLETE; 31 return RESPONSE_HEADERS_ARE_COMPLETE;
30 } 32 }
31 33
32 void ClosingDelegate::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {} 34 void ClosingDelegate::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {
35 }
33 36
34 void ClosingDelegate::OnDataSent() {} 37 void ClosingDelegate::OnDataSent() {
38 }
35 39
36 void ClosingDelegate::OnClose(int status) { 40 void ClosingDelegate::OnClose(int status) {
37 DCHECK(stream_); 41 DCHECK(stream_);
38 stream_->Close(); 42 stream_->Close();
39 // The |stream_| may still be alive (if it is our delegate). 43 // The |stream_| may still be alive (if it is our delegate).
40 } 44 }
41 45
42 StreamDelegateBase::StreamDelegateBase( 46 StreamDelegateBase::StreamDelegateBase(const base::WeakPtr<SpdyStream>& stream)
43 const base::WeakPtr<SpdyStream>& stream) 47 : stream_(stream), stream_id_(0), send_headers_completed_(false) {
44 : stream_(stream),
45 stream_id_(0),
46 send_headers_completed_(false) {
47 } 48 }
48 49
49 StreamDelegateBase::~StreamDelegateBase() { 50 StreamDelegateBase::~StreamDelegateBase() {
50 } 51 }
51 52
52 void StreamDelegateBase::OnRequestHeadersSent() { 53 void StreamDelegateBase::OnRequestHeadersSent() {
53 stream_id_ = stream_->stream_id(); 54 stream_id_ = stream_->stream_id();
54 EXPECT_NE(stream_id_, 0u); 55 EXPECT_NE(stream_id_, 0u);
55 send_headers_completed_ = true; 56 send_headers_completed_ = true;
56 } 57 }
57 58
58 SpdyResponseHeadersStatus StreamDelegateBase::OnResponseHeadersUpdated( 59 SpdyResponseHeadersStatus StreamDelegateBase::OnResponseHeadersUpdated(
59 const SpdyHeaderBlock& response_headers) { 60 const SpdyHeaderBlock& response_headers) {
60 EXPECT_EQ(stream_->type() != SPDY_PUSH_STREAM, send_headers_completed_); 61 EXPECT_EQ(stream_->type() != SPDY_PUSH_STREAM, send_headers_completed_);
61 response_headers_ = response_headers; 62 response_headers_ = response_headers;
62 return RESPONSE_HEADERS_ARE_COMPLETE; 63 return RESPONSE_HEADERS_ARE_COMPLETE;
63 } 64 }
64 65
65 void StreamDelegateBase::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { 66 void StreamDelegateBase::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {
66 if (buffer) 67 if (buffer)
67 received_data_queue_.Enqueue(buffer.Pass()); 68 received_data_queue_.Enqueue(buffer.Pass());
68 } 69 }
69 70
70 void StreamDelegateBase::OnDataSent() {} 71 void StreamDelegateBase::OnDataSent() {
72 }
71 73
72 void StreamDelegateBase::OnClose(int status) { 74 void StreamDelegateBase::OnClose(int status) {
73 if (!stream_.get()) 75 if (!stream_.get())
74 return; 76 return;
75 stream_id_ = stream_->stream_id(); 77 stream_id_ = stream_->stream_id();
76 stream_.reset(); 78 stream_.reset();
77 callback_.callback().Run(status); 79 callback_.callback().Run(status);
78 } 80 }
79 81
80 int StreamDelegateBase::WaitForClose() { 82 int StreamDelegateBase::WaitForClose() {
(...skipping 14 matching lines...) Expand all
95 } 97 }
96 98
97 std::string StreamDelegateBase::GetResponseHeaderValue( 99 std::string StreamDelegateBase::GetResponseHeaderValue(
98 const std::string& name) const { 100 const std::string& name) const {
99 SpdyHeaderBlock::const_iterator it = response_headers_.find(name); 101 SpdyHeaderBlock::const_iterator it = response_headers_.find(name);
100 return (it == response_headers_.end()) ? std::string() : it->second; 102 return (it == response_headers_.end()) ? std::string() : it->second;
101 } 103 }
102 104
103 StreamDelegateDoNothing::StreamDelegateDoNothing( 105 StreamDelegateDoNothing::StreamDelegateDoNothing(
104 const base::WeakPtr<SpdyStream>& stream) 106 const base::WeakPtr<SpdyStream>& stream)
105 : StreamDelegateBase(stream) {} 107 : StreamDelegateBase(stream) {
108 }
106 109
107 StreamDelegateDoNothing::~StreamDelegateDoNothing() { 110 StreamDelegateDoNothing::~StreamDelegateDoNothing() {
108 } 111 }
109 112
110 StreamDelegateSendImmediate::StreamDelegateSendImmediate( 113 StreamDelegateSendImmediate::StreamDelegateSendImmediate(
111 const base::WeakPtr<SpdyStream>& stream, 114 const base::WeakPtr<SpdyStream>& stream,
112 base::StringPiece data) 115 base::StringPiece data)
113 : StreamDelegateBase(stream), 116 : StreamDelegateBase(stream), data_(data) {
114 data_(data) {} 117 }
115 118
116 StreamDelegateSendImmediate::~StreamDelegateSendImmediate() { 119 StreamDelegateSendImmediate::~StreamDelegateSendImmediate() {
117 } 120 }
118 121
119 SpdyResponseHeadersStatus StreamDelegateSendImmediate::OnResponseHeadersUpdated( 122 SpdyResponseHeadersStatus StreamDelegateSendImmediate::OnResponseHeadersUpdated(
120 const SpdyHeaderBlock& response_headers) { 123 const SpdyHeaderBlock& response_headers) {
121 SpdyResponseHeadersStatus status = 124 SpdyResponseHeadersStatus status =
122 StreamDelegateBase::OnResponseHeadersUpdated(response_headers); 125 StreamDelegateBase::OnResponseHeadersUpdated(response_headers);
123 if (data_.data()) { 126 if (data_.data()) {
124 scoped_refptr<StringIOBuffer> buf(new StringIOBuffer(data_.as_string())); 127 scoped_refptr<StringIOBuffer> buf(new StringIOBuffer(data_.as_string()));
125 stream()->SendData(buf.get(), buf->size(), MORE_DATA_TO_SEND); 128 stream()->SendData(buf.get(), buf->size(), MORE_DATA_TO_SEND);
126 } 129 }
127 return status; 130 return status;
128 } 131 }
129 132
130 StreamDelegateWithBody::StreamDelegateWithBody( 133 StreamDelegateWithBody::StreamDelegateWithBody(
131 const base::WeakPtr<SpdyStream>& stream, 134 const base::WeakPtr<SpdyStream>& stream,
132 base::StringPiece data) 135 base::StringPiece data)
133 : StreamDelegateBase(stream), 136 : StreamDelegateBase(stream), buf_(new StringIOBuffer(data.as_string())) {
134 buf_(new StringIOBuffer(data.as_string())) {} 137 }
135 138
136 StreamDelegateWithBody::~StreamDelegateWithBody() { 139 StreamDelegateWithBody::~StreamDelegateWithBody() {
137 } 140 }
138 141
139 void StreamDelegateWithBody::OnRequestHeadersSent() { 142 void StreamDelegateWithBody::OnRequestHeadersSent() {
140 StreamDelegateBase::OnRequestHeadersSent(); 143 StreamDelegateBase::OnRequestHeadersSent();
141 stream()->SendData(buf_.get(), buf_->size(), NO_MORE_DATA_TO_SEND); 144 stream()->SendData(buf_.get(), buf_->size(), NO_MORE_DATA_TO_SEND);
142 } 145 }
143 146
144 } // namespace test 147 } // namespace test
145 148
146 } // namespace net 149 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698