OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 explicit DecompressionVisitor(SpdyMajorVersion version) | 75 explicit DecompressionVisitor(SpdyMajorVersion version) |
76 : version_(version), size_(0), finished_(false) {} | 76 : version_(version), size_(0), finished_(false) {} |
77 | 77 |
78 void ResetBuffer() { | 78 void ResetBuffer() { |
79 CHECK(buffer_.get() == NULL); | 79 CHECK(buffer_.get() == NULL); |
80 CHECK_EQ(0u, size_); | 80 CHECK_EQ(0u, size_); |
81 CHECK(!finished_); | 81 CHECK(!finished_); |
82 buffer_.reset(new char[kMaxDecompressedSize]); | 82 buffer_.reset(new char[kMaxDecompressedSize]); |
83 } | 83 } |
84 | 84 |
85 virtual void OnError(SpdyFramer* framer) OVERRIDE { LOG(FATAL); } | 85 virtual void OnError(SpdyFramer* framer) override { LOG(FATAL); } |
86 virtual void OnDataFrameHeader(SpdyStreamId stream_id, | 86 virtual void OnDataFrameHeader(SpdyStreamId stream_id, |
87 size_t length, | 87 size_t length, |
88 bool fin) OVERRIDE { | 88 bool fin) override { |
89 LOG(FATAL) << "Unexpected data frame header"; | 89 LOG(FATAL) << "Unexpected data frame header"; |
90 } | 90 } |
91 virtual void OnStreamFrameData(SpdyStreamId stream_id, | 91 virtual void OnStreamFrameData(SpdyStreamId stream_id, |
92 const char* data, | 92 const char* data, |
93 size_t len, | 93 size_t len, |
94 bool fin) OVERRIDE { | 94 bool fin) override { |
95 LOG(FATAL); | 95 LOG(FATAL); |
96 } | 96 } |
97 | 97 |
98 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, | 98 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, |
99 const char* header_data, | 99 const char* header_data, |
100 size_t len) OVERRIDE { | 100 size_t len) override { |
101 CHECK(buffer_.get() != NULL); | 101 CHECK(buffer_.get() != NULL); |
102 CHECK_GE(kMaxDecompressedSize, size_ + len); | 102 CHECK_GE(kMaxDecompressedSize, size_ + len); |
103 CHECK(!finished_); | 103 CHECK(!finished_); |
104 if (len != 0) { | 104 if (len != 0) { |
105 memcpy(buffer_.get() + size_, header_data, len); | 105 memcpy(buffer_.get() + size_, header_data, len); |
106 size_ += len; | 106 size_ += len; |
107 } else { | 107 } else { |
108 // Done. | 108 // Done. |
109 finished_ = true; | 109 finished_ = true; |
110 } | 110 } |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 virtual void OnSynStream(SpdyStreamId stream_id, | 114 virtual void OnSynStream(SpdyStreamId stream_id, |
115 SpdyStreamId associated_stream_id, | 115 SpdyStreamId associated_stream_id, |
116 SpdyPriority priority, | 116 SpdyPriority priority, |
117 bool fin, | 117 bool fin, |
118 bool unidirectional) OVERRIDE { | 118 bool unidirectional) override { |
119 SpdyFramer framer(version_); | 119 SpdyFramer framer(version_); |
120 framer.set_enable_compression(false); | 120 framer.set_enable_compression(false); |
121 SpdySynStreamIR syn_stream(stream_id); | 121 SpdySynStreamIR syn_stream(stream_id); |
122 syn_stream.set_associated_to_stream_id(associated_stream_id); | 122 syn_stream.set_associated_to_stream_id(associated_stream_id); |
123 syn_stream.set_priority(priority); | 123 syn_stream.set_priority(priority); |
124 syn_stream.set_fin(fin); | 124 syn_stream.set_fin(fin); |
125 syn_stream.set_unidirectional(unidirectional); | 125 syn_stream.set_unidirectional(unidirectional); |
126 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); | 126 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); |
127 ResetBuffer(); | 127 ResetBuffer(); |
128 memcpy(buffer_.get(), frame->data(), framer.GetSynStreamMinimumSize()); | 128 memcpy(buffer_.get(), frame->data(), framer.GetSynStreamMinimumSize()); |
129 size_ += framer.GetSynStreamMinimumSize(); | 129 size_ += framer.GetSynStreamMinimumSize(); |
130 } | 130 } |
131 | 131 |
132 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { | 132 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) override { |
133 SpdyFramer framer(version_); | 133 SpdyFramer framer(version_); |
134 framer.set_enable_compression(false); | 134 framer.set_enable_compression(false); |
135 SpdyHeadersIR headers(stream_id); | 135 SpdyHeadersIR headers(stream_id); |
136 headers.set_fin(fin); | 136 headers.set_fin(fin); |
137 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers)); | 137 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers)); |
138 ResetBuffer(); | 138 ResetBuffer(); |
139 memcpy(buffer_.get(), frame->data(), framer.GetHeadersMinimumSize()); | 139 memcpy(buffer_.get(), frame->data(), framer.GetHeadersMinimumSize()); |
140 size_ += framer.GetSynStreamMinimumSize(); | 140 size_ += framer.GetSynStreamMinimumSize(); |
141 } | 141 } |
142 | 142 |
143 virtual void OnRstStream(SpdyStreamId stream_id, | 143 virtual void OnRstStream(SpdyStreamId stream_id, |
144 SpdyRstStreamStatus status) OVERRIDE { | 144 SpdyRstStreamStatus status) override { |
145 LOG(FATAL); | 145 LOG(FATAL); |
146 } | 146 } |
147 virtual void OnSetting(SpdySettingsIds id, | 147 virtual void OnSetting(SpdySettingsIds id, |
148 uint8 flags, | 148 uint8 flags, |
149 uint32 value) OVERRIDE { | 149 uint32 value) override { |
150 LOG(FATAL); | 150 LOG(FATAL); |
151 } | 151 } |
152 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE { | 152 virtual void OnPing(SpdyPingId unique_id, bool is_ack) override { |
153 LOG(FATAL); | 153 LOG(FATAL); |
154 } | 154 } |
155 virtual void OnSettingsEnd() OVERRIDE { LOG(FATAL); } | 155 virtual void OnSettingsEnd() override { LOG(FATAL); } |
156 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, | 156 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, |
157 SpdyGoAwayStatus status) OVERRIDE { | 157 SpdyGoAwayStatus status) override { |
158 LOG(FATAL); | 158 LOG(FATAL); |
159 } | 159 } |
160 | 160 |
161 virtual void OnHeaders(SpdyStreamId stream_id, | 161 virtual void OnHeaders(SpdyStreamId stream_id, |
162 bool fin, | 162 bool fin, |
163 bool end) OVERRIDE { | 163 bool end) override { |
164 SpdyFramer framer(version_); | 164 SpdyFramer framer(version_); |
165 framer.set_enable_compression(false); | 165 framer.set_enable_compression(false); |
166 SpdyHeadersIR headers(stream_id); | 166 SpdyHeadersIR headers(stream_id); |
167 headers.set_fin(fin); | 167 headers.set_fin(fin); |
168 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers)); | 168 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers)); |
169 ResetBuffer(); | 169 ResetBuffer(); |
170 memcpy(buffer_.get(), frame->data(), framer.GetHeadersMinimumSize()); | 170 memcpy(buffer_.get(), frame->data(), framer.GetHeadersMinimumSize()); |
171 size_ += framer.GetHeadersMinimumSize(); | 171 size_ += framer.GetHeadersMinimumSize(); |
172 } | 172 } |
173 | 173 |
174 virtual void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) { | 174 virtual void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) { |
175 LOG(FATAL); | 175 LOG(FATAL); |
176 } | 176 } |
177 | 177 |
178 virtual void OnPushPromise(SpdyStreamId stream_id, | 178 virtual void OnPushPromise(SpdyStreamId stream_id, |
179 SpdyStreamId promised_stream_id, | 179 SpdyStreamId promised_stream_id, |
180 bool end) OVERRIDE { | 180 bool end) override { |
181 SpdyFramer framer(version_); | 181 SpdyFramer framer(version_); |
182 framer.set_enable_compression(false); | 182 framer.set_enable_compression(false); |
183 SpdyPushPromiseIR push_promise(stream_id, promised_stream_id); | 183 SpdyPushPromiseIR push_promise(stream_id, promised_stream_id); |
184 scoped_ptr<SpdyFrame> frame(framer.SerializePushPromise(push_promise)); | 184 scoped_ptr<SpdyFrame> frame(framer.SerializePushPromise(push_promise)); |
185 ResetBuffer(); | 185 ResetBuffer(); |
186 memcpy(buffer_.get(), frame->data(), framer.GetPushPromiseMinimumSize()); | 186 memcpy(buffer_.get(), frame->data(), framer.GetPushPromiseMinimumSize()); |
187 size_ += framer.GetPushPromiseMinimumSize(); | 187 size_ += framer.GetPushPromiseMinimumSize(); |
188 } | 188 } |
189 | 189 |
190 virtual void OnContinuation(SpdyStreamId stream_id, bool end) OVERRIDE { | 190 virtual void OnContinuation(SpdyStreamId stream_id, bool end) override { |
191 LOG(FATAL); | 191 LOG(FATAL); |
192 } | 192 } |
193 | 193 |
194 virtual void OnPriority(SpdyStreamId stream_id, | 194 virtual void OnPriority(SpdyStreamId stream_id, |
195 SpdyStreamId parent_stream_id, | 195 SpdyStreamId parent_stream_id, |
196 uint8 weight, | 196 uint8 weight, |
197 bool exclusive) OVERRIDE { | 197 bool exclusive) override { |
198 // Do nothing. | 198 // Do nothing. |
199 } | 199 } |
200 | 200 |
201 virtual bool OnUnknownFrame(SpdyStreamId stream_id, | 201 virtual bool OnUnknownFrame(SpdyStreamId stream_id, |
202 int frame_type) OVERRIDE { | 202 int frame_type) override { |
203 LOG(FATAL); | 203 LOG(FATAL); |
204 return false; | 204 return false; |
205 } | 205 } |
206 | 206 |
207 char* ReleaseBuffer() { | 207 char* ReleaseBuffer() { |
208 CHECK(finished_); | 208 CHECK(finished_); |
209 return buffer_.release(); | 209 return buffer_.release(); |
210 } | 210 } |
211 | 211 |
212 virtual void OnWindowUpdate(SpdyStreamId stream_id, | 212 virtual void OnWindowUpdate(SpdyStreamId stream_id, |
213 uint32 delta_window_size) OVERRIDE { | 213 uint32 delta_window_size) override { |
214 LOG(FATAL); | 214 LOG(FATAL); |
215 } | 215 } |
216 | 216 |
217 size_t size() const { | 217 size_t size() const { |
218 CHECK(finished_); | 218 CHECK(finished_); |
219 return size_; | 219 return size_; |
220 } | 220 } |
221 | 221 |
222 private: | 222 private: |
223 SpdyMajorVersion version_; | 223 SpdyMajorVersion version_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 data_frame_count_(0), | 270 data_frame_count_(0), |
271 last_payload_len_(0), | 271 last_payload_len_(0), |
272 last_frame_len_(0), | 272 last_frame_len_(0), |
273 header_buffer_(new char[kDefaultHeaderBufferSize]), | 273 header_buffer_(new char[kDefaultHeaderBufferSize]), |
274 header_buffer_length_(0), | 274 header_buffer_length_(0), |
275 header_buffer_size_(kDefaultHeaderBufferSize), | 275 header_buffer_size_(kDefaultHeaderBufferSize), |
276 header_stream_id_(static_cast<SpdyStreamId>(-1)), | 276 header_stream_id_(static_cast<SpdyStreamId>(-1)), |
277 header_control_type_(DATA), | 277 header_control_type_(DATA), |
278 header_buffer_valid_(false) {} | 278 header_buffer_valid_(false) {} |
279 | 279 |
280 virtual void OnError(SpdyFramer* f) OVERRIDE { | 280 virtual void OnError(SpdyFramer* f) override { |
281 LOG(INFO) << "SpdyFramer Error: " | 281 LOG(INFO) << "SpdyFramer Error: " |
282 << SpdyFramer::ErrorCodeToString(f->error_code()); | 282 << SpdyFramer::ErrorCodeToString(f->error_code()); |
283 ++error_count_; | 283 ++error_count_; |
284 } | 284 } |
285 | 285 |
286 virtual void OnDataFrameHeader(SpdyStreamId stream_id, | 286 virtual void OnDataFrameHeader(SpdyStreamId stream_id, |
287 size_t length, | 287 size_t length, |
288 bool fin) OVERRIDE { | 288 bool fin) override { |
289 ++data_frame_count_; | 289 ++data_frame_count_; |
290 header_stream_id_ = stream_id; | 290 header_stream_id_ = stream_id; |
291 } | 291 } |
292 | 292 |
293 virtual void OnStreamFrameData(SpdyStreamId stream_id, | 293 virtual void OnStreamFrameData(SpdyStreamId stream_id, |
294 const char* data, | 294 const char* data, |
295 size_t len, | 295 size_t len, |
296 bool fin) OVERRIDE { | 296 bool fin) override { |
297 EXPECT_EQ(header_stream_id_, stream_id); | 297 EXPECT_EQ(header_stream_id_, stream_id); |
298 if (len == 0) | 298 if (len == 0) |
299 ++zero_length_data_frame_count_; | 299 ++zero_length_data_frame_count_; |
300 | 300 |
301 data_bytes_ += len; | 301 data_bytes_ += len; |
302 std::cerr << "OnStreamFrameData(" << stream_id << ", \""; | 302 std::cerr << "OnStreamFrameData(" << stream_id << ", \""; |
303 if (len > 0) { | 303 if (len > 0) { |
304 for (size_t i = 0 ; i < len; ++i) { | 304 for (size_t i = 0 ; i < len; ++i) { |
305 std::cerr << std::hex << (0xFF & (unsigned int)data[i]) << std::dec; | 305 std::cerr << std::hex << (0xFF & (unsigned int)data[i]) << std::dec; |
306 } | 306 } |
307 } | 307 } |
308 std::cerr << "\", " << len << ")\n"; | 308 std::cerr << "\", " << len << ")\n"; |
309 } | 309 } |
310 | 310 |
311 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, | 311 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, |
312 const char* header_data, | 312 const char* header_data, |
313 size_t len) OVERRIDE { | 313 size_t len) override { |
314 ++control_frame_header_data_count_; | 314 ++control_frame_header_data_count_; |
315 CHECK_EQ(header_stream_id_, stream_id); | 315 CHECK_EQ(header_stream_id_, stream_id); |
316 if (len == 0) { | 316 if (len == 0) { |
317 ++zero_length_control_frame_header_data_count_; | 317 ++zero_length_control_frame_header_data_count_; |
318 // Indicates end-of-header-block. | 318 // Indicates end-of-header-block. |
319 headers_.clear(); | 319 headers_.clear(); |
320 CHECK(header_buffer_valid_); | 320 CHECK(header_buffer_valid_); |
321 size_t parsed_length = framer_.ParseHeaderBlockInBuffer( | 321 size_t parsed_length = framer_.ParseHeaderBlockInBuffer( |
322 header_buffer_.get(), header_buffer_length_, &headers_); | 322 header_buffer_.get(), header_buffer_length_, &headers_); |
323 LOG_IF(DFATAL, header_buffer_length_ != parsed_length) | 323 LOG_IF(DFATAL, header_buffer_length_ != parsed_length) |
324 << "Check failed: header_buffer_length_ == parsed_length " | 324 << "Check failed: header_buffer_length_ == parsed_length " |
325 << "(" << header_buffer_length_ << " vs. " << parsed_length << ")"; | 325 << "(" << header_buffer_length_ << " vs. " << parsed_length << ")"; |
326 return true; | 326 return true; |
327 } | 327 } |
328 const size_t available = header_buffer_size_ - header_buffer_length_; | 328 const size_t available = header_buffer_size_ - header_buffer_length_; |
329 if (len > available) { | 329 if (len > available) { |
330 header_buffer_valid_ = false; | 330 header_buffer_valid_ = false; |
331 return false; | 331 return false; |
332 } | 332 } |
333 memcpy(header_buffer_.get() + header_buffer_length_, header_data, len); | 333 memcpy(header_buffer_.get() + header_buffer_length_, header_data, len); |
334 header_buffer_length_ += len; | 334 header_buffer_length_ += len; |
335 return true; | 335 return true; |
336 } | 336 } |
337 | 337 |
338 virtual void OnSynStream(SpdyStreamId stream_id, | 338 virtual void OnSynStream(SpdyStreamId stream_id, |
339 SpdyStreamId associated_stream_id, | 339 SpdyStreamId associated_stream_id, |
340 SpdyPriority priority, | 340 SpdyPriority priority, |
341 bool fin, | 341 bool fin, |
342 bool unidirectional) OVERRIDE { | 342 bool unidirectional) override { |
343 ++syn_frame_count_; | 343 ++syn_frame_count_; |
344 if (framer_.protocol_version() > SPDY3) { | 344 if (framer_.protocol_version() > SPDY3) { |
345 InitHeaderStreaming(HEADERS, stream_id); | 345 InitHeaderStreaming(HEADERS, stream_id); |
346 } else { | 346 } else { |
347 InitHeaderStreaming(SYN_STREAM, stream_id); | 347 InitHeaderStreaming(SYN_STREAM, stream_id); |
348 } | 348 } |
349 if (fin) { | 349 if (fin) { |
350 ++fin_flag_count_; | 350 ++fin_flag_count_; |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { | 354 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) override { |
355 ++syn_reply_frame_count_; | 355 ++syn_reply_frame_count_; |
356 if (framer_.protocol_version() > SPDY3) { | 356 if (framer_.protocol_version() > SPDY3) { |
357 InitHeaderStreaming(HEADERS, stream_id); | 357 InitHeaderStreaming(HEADERS, stream_id); |
358 } else { | 358 } else { |
359 InitHeaderStreaming(SYN_REPLY, stream_id); | 359 InitHeaderStreaming(SYN_REPLY, stream_id); |
360 } | 360 } |
361 if (fin) { | 361 if (fin) { |
362 ++fin_flag_count_; | 362 ++fin_flag_count_; |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 virtual void OnRstStream(SpdyStreamId stream_id, | 366 virtual void OnRstStream(SpdyStreamId stream_id, |
367 SpdyRstStreamStatus status) OVERRIDE { | 367 SpdyRstStreamStatus status) override { |
368 ++fin_frame_count_; | 368 ++fin_frame_count_; |
369 } | 369 } |
370 | 370 |
371 virtual bool OnRstStreamFrameData(const char* rst_stream_data, | 371 virtual bool OnRstStreamFrameData(const char* rst_stream_data, |
372 size_t len) OVERRIDE { | 372 size_t len) override { |
373 if ((rst_stream_data != NULL) && (len > 0)) { | 373 if ((rst_stream_data != NULL) && (len > 0)) { |
374 fin_opaque_data_ += std::string(rst_stream_data, len); | 374 fin_opaque_data_ += std::string(rst_stream_data, len); |
375 } | 375 } |
376 return true; | 376 return true; |
377 } | 377 } |
378 | 378 |
379 virtual void OnSetting(SpdySettingsIds id, | 379 virtual void OnSetting(SpdySettingsIds id, |
380 uint8 flags, | 380 uint8 flags, |
381 uint32 value) OVERRIDE { | 381 uint32 value) override { |
382 ++setting_count_; | 382 ++setting_count_; |
383 } | 383 } |
384 | 384 |
385 virtual void OnSettingsAck() OVERRIDE { | 385 virtual void OnSettingsAck() override { |
386 DCHECK_LT(SPDY3, framer_.protocol_version()); | 386 DCHECK_LT(SPDY3, framer_.protocol_version()); |
387 ++settings_ack_received_; | 387 ++settings_ack_received_; |
388 } | 388 } |
389 | 389 |
390 virtual void OnSettingsEnd() OVERRIDE { | 390 virtual void OnSettingsEnd() override { |
391 if (framer_.protocol_version() <= SPDY3) { return; } | 391 if (framer_.protocol_version() <= SPDY3) { return; } |
392 ++settings_ack_sent_; | 392 ++settings_ack_sent_; |
393 } | 393 } |
394 | 394 |
395 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE { | 395 virtual void OnPing(SpdyPingId unique_id, bool is_ack) override { |
396 DLOG(FATAL); | 396 DLOG(FATAL); |
397 } | 397 } |
398 | 398 |
399 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, | 399 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, |
400 SpdyGoAwayStatus status) OVERRIDE { | 400 SpdyGoAwayStatus status) override { |
401 ++goaway_count_; | 401 ++goaway_count_; |
402 } | 402 } |
403 | 403 |
404 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) OVERRIDE { | 404 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) override { |
405 ++headers_frame_count_; | 405 ++headers_frame_count_; |
406 InitHeaderStreaming(HEADERS, stream_id); | 406 InitHeaderStreaming(HEADERS, stream_id); |
407 if (fin) { | 407 if (fin) { |
408 ++fin_flag_count_; | 408 ++fin_flag_count_; |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 virtual void OnWindowUpdate(SpdyStreamId stream_id, | 412 virtual void OnWindowUpdate(SpdyStreamId stream_id, |
413 uint32 delta_window_size) OVERRIDE { | 413 uint32 delta_window_size) override { |
414 last_window_update_stream_ = stream_id; | 414 last_window_update_stream_ = stream_id; |
415 last_window_update_delta_ = delta_window_size; | 415 last_window_update_delta_ = delta_window_size; |
416 } | 416 } |
417 | 417 |
418 virtual void OnPushPromise(SpdyStreamId stream_id, | 418 virtual void OnPushPromise(SpdyStreamId stream_id, |
419 SpdyStreamId promised_stream_id, | 419 SpdyStreamId promised_stream_id, |
420 bool end) OVERRIDE { | 420 bool end) override { |
421 ++push_promise_frame_count_; | 421 ++push_promise_frame_count_; |
422 InitHeaderStreaming(PUSH_PROMISE, stream_id); | 422 InitHeaderStreaming(PUSH_PROMISE, stream_id); |
423 last_push_promise_stream_ = stream_id; | 423 last_push_promise_stream_ = stream_id; |
424 last_push_promise_promised_stream_ = promised_stream_id; | 424 last_push_promise_promised_stream_ = promised_stream_id; |
425 } | 425 } |
426 | 426 |
427 virtual void OnContinuation(SpdyStreamId stream_id, bool end) OVERRIDE { | 427 virtual void OnContinuation(SpdyStreamId stream_id, bool end) override { |
428 ++continuation_count_; | 428 ++continuation_count_; |
429 } | 429 } |
430 | 430 |
431 virtual void OnAltSvc(SpdyStreamId stream_id, | 431 virtual void OnAltSvc(SpdyStreamId stream_id, |
432 uint32 max_age, | 432 uint32 max_age, |
433 uint16 port, | 433 uint16 port, |
434 StringPiece protocol_id, | 434 StringPiece protocol_id, |
435 StringPiece host, | 435 StringPiece host, |
436 StringPiece origin) OVERRIDE { | 436 StringPiece origin) override { |
437 test_altsvc_ir_.set_stream_id(stream_id); | 437 test_altsvc_ir_.set_stream_id(stream_id); |
438 test_altsvc_ir_.set_max_age(max_age); | 438 test_altsvc_ir_.set_max_age(max_age); |
439 test_altsvc_ir_.set_port(port); | 439 test_altsvc_ir_.set_port(port); |
440 test_altsvc_ir_.set_protocol_id(protocol_id.as_string()); | 440 test_altsvc_ir_.set_protocol_id(protocol_id.as_string()); |
441 test_altsvc_ir_.set_host(host.as_string()); | 441 test_altsvc_ir_.set_host(host.as_string()); |
442 if (origin.length() > 0) { | 442 if (origin.length() > 0) { |
443 test_altsvc_ir_.set_origin(origin.as_string()); | 443 test_altsvc_ir_.set_origin(origin.as_string()); |
444 } | 444 } |
445 ++altsvc_count_; | 445 ++altsvc_count_; |
446 } | 446 } |
447 | 447 |
448 virtual void OnPriority(SpdyStreamId stream_id, | 448 virtual void OnPriority(SpdyStreamId stream_id, |
449 SpdyStreamId parent_stream_id, | 449 SpdyStreamId parent_stream_id, |
450 uint8 weight, | 450 uint8 weight, |
451 bool exclusive) OVERRIDE { | 451 bool exclusive) override { |
452 ++priority_count_; | 452 ++priority_count_; |
453 } | 453 } |
454 | 454 |
455 virtual bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) OVERRIDE { | 455 virtual bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override { |
456 DLOG(INFO) << "Unknown frame type " << frame_type; | 456 DLOG(INFO) << "Unknown frame type " << frame_type; |
457 return on_unknown_frame_result_; | 457 return on_unknown_frame_result_; |
458 } | 458 } |
459 | 459 |
460 virtual void OnSendCompressedFrame(SpdyStreamId stream_id, | 460 virtual void OnSendCompressedFrame(SpdyStreamId stream_id, |
461 SpdyFrameType type, | 461 SpdyFrameType type, |
462 size_t payload_len, | 462 size_t payload_len, |
463 size_t frame_len) OVERRIDE { | 463 size_t frame_len) override { |
464 last_payload_len_ = payload_len; | 464 last_payload_len_ = payload_len; |
465 last_frame_len_ = frame_len; | 465 last_frame_len_ = frame_len; |
466 } | 466 } |
467 | 467 |
468 virtual void OnReceiveCompressedFrame(SpdyStreamId stream_id, | 468 virtual void OnReceiveCompressedFrame(SpdyStreamId stream_id, |
469 SpdyFrameType type, | 469 SpdyFrameType type, |
470 size_t frame_len) OVERRIDE { | 470 size_t frame_len) override { |
471 last_frame_len_ = frame_len; | 471 last_frame_len_ = frame_len; |
472 } | 472 } |
473 | 473 |
474 // Convenience function which runs a framer simulation with particular input. | 474 // Convenience function which runs a framer simulation with particular input. |
475 void SimulateInFramer(const unsigned char* input, size_t size) { | 475 void SimulateInFramer(const unsigned char* input, size_t size) { |
476 framer_.set_enable_compression(use_compression_); | 476 framer_.set_enable_compression(use_compression_); |
477 framer_.set_visitor(this); | 477 framer_.set_visitor(this); |
478 size_t input_remaining = size; | 478 size_t input_remaining = size; |
479 const char* input_ptr = reinterpret_cast<const char*>(input); | 479 const char* input_ptr = reinterpret_cast<const char*>(input); |
480 while (input_remaining > 0 && | 480 while (input_remaining > 0 && |
(...skipping 5068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5549 TestSpdyVisitor visitor(spdy_version_); | 5549 TestSpdyVisitor visitor(spdy_version_); |
5550 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5550 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
5551 | 5551 |
5552 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5552 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
5553 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5553 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
5554 visitor.framer_.error_code()) | 5554 visitor.framer_.error_code()) |
5555 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5555 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
5556 } | 5556 } |
5557 | 5557 |
5558 } // namespace net | 5558 } // namespace net |
OLD | NEW |