OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_SPDY_SPDY_TEST_UTIL_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_H_ |
6 #define NET_SPDY_SPDY_TEST_UTIL_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "net/base/request_priority.h" |
9 #include "net/socket/socket_test_util.h" | 10 #include "net/socket/socket_test_util.h" |
10 #include "net/spdy/spdy_framer.h" | 11 #include "net/spdy/spdy_framer.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
14 // NOTE: In GCC, on a Mac, this can't be in an anonymous namespace! | 15 // NOTE: In GCC, on a Mac, this can't be in an anonymous namespace! |
15 // This struct holds information used to construct spdy control and data frames. | 16 // This struct holds information used to construct spdy control and data frames. |
16 struct SpdyHeaderInfo { | 17 struct SpdyHeaderInfo { |
17 spdy::SpdyControlType kind; | 18 spdy::SpdyControlType kind; |
18 spdy::SpdyStreamId id; | 19 spdy::SpdyStreamId id; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 char* buffer, | 131 char* buffer, |
131 int buffer_length, | 132 int buffer_length, |
132 int index); | 133 int index); |
133 | 134 |
134 // Constructs a standard SPDY GET SYN packet, optionally compressed. | 135 // Constructs a standard SPDY GET SYN packet, optionally compressed. |
135 // |extra_headers| are the extra header-value pairs, which typically | 136 // |extra_headers| are the extra header-value pairs, which typically |
136 // will vary the most between calls. | 137 // will vary the most between calls. |
137 // Returns a SpdyFrame. | 138 // Returns a SpdyFrame. |
138 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], | 139 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], |
139 int extra_header_count, | 140 int extra_header_count, |
140 bool compressed); | 141 bool compressed, |
141 | 142 int stream_id, |
142 // Constructs a standard SPDY GET SYN packet, with no compression. | 143 RequestPriority request_priority); |
143 // |extra_headers| are the extra header-value pairs, which typically | |
144 // will vary the most between calls. | |
145 // Returns a SpdyFrame. | |
146 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], | |
147 int extra_header_count); | |
148 | 144 |
149 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. | 145 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. |
150 // |extra_headers| are the extra header-value pairs, which typically | 146 // |extra_headers| are the extra header-value pairs, which typically |
151 // will vary the most between calls. | 147 // will vary the most between calls. |
152 // Returns a SpdyFrame. | 148 // Returns a SpdyFrame. |
153 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], | 149 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], |
154 int extra_header_count); | 150 int extra_header_count, |
| 151 int stream_id); |
155 | 152 |
156 // Constructs a standard SPDY POST SYN packet. | 153 // Constructs a standard SPDY POST SYN packet. |
157 // |extra_headers| are the extra header-value pairs, which typically | 154 // |extra_headers| are the extra header-value pairs, which typically |
158 // will vary the most between calls. | 155 // will vary the most between calls. |
159 // Returns a SpdyFrame. | 156 // Returns a SpdyFrame. |
160 spdy::SpdyFrame* ConstructSpdyPost(const char* const extra_headers[], | 157 spdy::SpdyFrame* ConstructSpdyPost(const char* const extra_headers[], |
161 int extra_header_count); | 158 int extra_header_count); |
162 | 159 |
163 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. | 160 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. |
164 // |extra_headers| are the extra header-value pairs, which typically | 161 // |extra_headers| are the extra header-value pairs, which typically |
165 // will vary the most between calls. | 162 // will vary the most between calls. |
166 // Returns a SpdyFrame. | 163 // Returns a SpdyFrame. |
167 spdy::SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], | 164 spdy::SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], |
168 int extra_header_count); | 165 int extra_header_count); |
169 | 166 |
170 // Constructs a single SPDY data frame with the contents "hello!" | 167 // Constructs a single SPDY data frame with the contents "hello!" |
171 spdy::SpdyFrame* ConstructSpdyBodyFrame(); | 168 spdy::SpdyFrame* ConstructSpdyBodyFrame(int stream_id, |
| 169 bool fin); |
172 | 170 |
173 // Create an async MockWrite from the given SpdyFrame. | 171 // Create an async MockWrite from the given SpdyFrame. |
174 MockWrite CreateMockWrite(const spdy::SpdyFrame& req); | 172 MockWrite CreateMockWrite(const spdy::SpdyFrame& req); |
175 | 173 |
176 // Create an async MockWrite from the given SpdyFrame and sequence number. | 174 // Create an async MockWrite from the given SpdyFrame and sequence number. |
177 MockWrite CreateMockWrite(const spdy::SpdyFrame& req, int seq); | 175 MockWrite CreateMockWrite(const spdy::SpdyFrame& req, int seq); |
178 | 176 |
179 // Create a MockRead from the given SpdyFrame. | 177 // Create a MockRead from the given SpdyFrame. |
180 MockRead CreateMockRead(const spdy::SpdyFrame& resp); | 178 MockRead CreateMockRead(const spdy::SpdyFrame& resp); |
181 | 179 |
182 // Create a MockRead from the given SpdyFrame and sequence number. | 180 // Create a MockRead from the given SpdyFrame and sequence number. |
183 MockRead CreateMockRead(const spdy::SpdyFrame& resp, int seq); | 181 MockRead CreateMockRead(const spdy::SpdyFrame& resp, int seq); |
184 | 182 |
185 // Combines the given SpdyFrames into the given char array and returns | 183 // Combines the given SpdyFrames into the given char array and returns |
186 // the total length. | 184 // the total length. |
187 int CombineFrames(const spdy::SpdyFrame** frames, int num_frames, | 185 int CombineFrames(const spdy::SpdyFrame** frames, int num_frames, |
188 char* buff, int buff_len); | 186 char* buff, int buff_len); |
189 | 187 |
190 } // namespace net | 188 } // namespace net |
191 | 189 |
192 #endif // NET_SPDY_SPDY_TEST_UTIL_H_ | 190 #endif // NET_SPDY_SPDY_TEST_UTIL_H_ |
OLD | NEW |