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 "net/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 for (size_t i = 0; i < N; ++i) { | 331 for (size_t i = 0; i < N; ++i) { |
332 total_size += arr[i].size(); | 332 total_size += arr[i].size(); |
333 } | 333 } |
334 return total_size; | 334 return total_size; |
335 } | 335 } |
336 | 336 |
337 // Helper class for std:find_if on STL container containing | 337 // Helper class for std:find_if on STL container containing |
338 // SpdyStreamRequest weak pointers. | 338 // SpdyStreamRequest weak pointers. |
339 class RequestEquals { | 339 class RequestEquals { |
340 public: | 340 public: |
341 RequestEquals(const base::WeakPtr<SpdyStreamRequest>& request) | 341 explicit RequestEquals(const base::WeakPtr<SpdyStreamRequest>& request) |
342 : request_(request) {} | 342 : request_(request) {} |
343 | 343 |
344 bool operator()(const base::WeakPtr<SpdyStreamRequest>& request) const { | 344 bool operator()(const base::WeakPtr<SpdyStreamRequest>& request) const { |
345 return request_.get() == request.get(); | 345 return request_.get() == request.get(); |
346 } | 346 } |
347 | 347 |
348 private: | 348 private: |
349 const base::WeakPtr<SpdyStreamRequest> request_; | 349 const base::WeakPtr<SpdyStreamRequest> request_; |
350 }; | 350 }; |
351 | 351 |
352 // The maximum number of concurrent streams we will ever create. Even if | 352 // The maximum number of concurrent streams we will ever create. Even if |
353 // the server permits more, we will never exceed this limit. | 353 // the server permits more, we will never exceed this limit. |
354 const size_t kMaxConcurrentStreamLimit = 256; | 354 const size_t kMaxConcurrentStreamLimit = 256; |
355 | 355 |
356 } // namespace | 356 } // namespace |
357 | 357 |
358 SpdyProtocolErrorDetails MapFramerErrorToProtocolError( | 358 SpdyProtocolErrorDetails MapFramerErrorToProtocolError( |
359 SpdyFramer::SpdyError err) { | 359 SpdyFramer::SpdyError err) { |
360 switch(err) { | 360 switch (err) { |
361 case SpdyFramer::SPDY_NO_ERROR: | 361 case SpdyFramer::SPDY_NO_ERROR: |
362 return SPDY_ERROR_NO_ERROR; | 362 return SPDY_ERROR_NO_ERROR; |
363 case SpdyFramer::SPDY_INVALID_CONTROL_FRAME: | 363 case SpdyFramer::SPDY_INVALID_CONTROL_FRAME: |
364 return SPDY_ERROR_INVALID_CONTROL_FRAME; | 364 return SPDY_ERROR_INVALID_CONTROL_FRAME; |
365 case SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE: | 365 case SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE: |
366 return SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE; | 366 return SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE; |
367 case SpdyFramer::SPDY_ZLIB_INIT_FAILURE: | 367 case SpdyFramer::SPDY_ZLIB_INIT_FAILURE: |
368 return SPDY_ERROR_ZLIB_INIT_FAILURE; | 368 return SPDY_ERROR_ZLIB_INIT_FAILURE; |
369 case SpdyFramer::SPDY_UNSUPPORTED_VERSION: | 369 case SpdyFramer::SPDY_UNSUPPORTED_VERSION: |
370 return SPDY_ERROR_UNSUPPORTED_VERSION; | 370 return SPDY_ERROR_UNSUPPORTED_VERSION; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 case SpdyFramer::SPDY_UNEXPECTED_FRAME: | 415 case SpdyFramer::SPDY_UNEXPECTED_FRAME: |
416 return ERR_SPDY_PROTOCOL_ERROR; | 416 return ERR_SPDY_PROTOCOL_ERROR; |
417 default: | 417 default: |
418 NOTREACHED(); | 418 NOTREACHED(); |
419 return ERR_SPDY_PROTOCOL_ERROR; | 419 return ERR_SPDY_PROTOCOL_ERROR; |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 SpdyProtocolErrorDetails MapRstStreamStatusToProtocolError( | 423 SpdyProtocolErrorDetails MapRstStreamStatusToProtocolError( |
424 SpdyRstStreamStatus status) { | 424 SpdyRstStreamStatus status) { |
425 switch(status) { | 425 switch (status) { |
426 case RST_STREAM_PROTOCOL_ERROR: | 426 case RST_STREAM_PROTOCOL_ERROR: |
427 return STATUS_CODE_PROTOCOL_ERROR; | 427 return STATUS_CODE_PROTOCOL_ERROR; |
428 case RST_STREAM_INVALID_STREAM: | 428 case RST_STREAM_INVALID_STREAM: |
429 return STATUS_CODE_INVALID_STREAM; | 429 return STATUS_CODE_INVALID_STREAM; |
430 case RST_STREAM_REFUSED_STREAM: | 430 case RST_STREAM_REFUSED_STREAM: |
431 return STATUS_CODE_REFUSED_STREAM; | 431 return STATUS_CODE_REFUSED_STREAM; |
432 case RST_STREAM_UNSUPPORTED_VERSION: | 432 case RST_STREAM_UNSUPPORTED_VERSION: |
433 return STATUS_CODE_UNSUPPORTED_VERSION; | 433 return STATUS_CODE_UNSUPPORTED_VERSION; |
434 case RST_STREAM_CANCEL: | 434 case RST_STREAM_CANCEL: |
435 return STATUS_CODE_CANCEL; | 435 return STATUS_CODE_CANCEL; |
(...skipping 2918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3354 if (!queue->empty()) { | 3354 if (!queue->empty()) { |
3355 SpdyStreamId stream_id = queue->front(); | 3355 SpdyStreamId stream_id = queue->front(); |
3356 queue->pop_front(); | 3356 queue->pop_front(); |
3357 return stream_id; | 3357 return stream_id; |
3358 } | 3358 } |
3359 } | 3359 } |
3360 return 0; | 3360 return 0; |
3361 } | 3361 } |
3362 | 3362 |
3363 } // namespace net | 3363 } // namespace net |
OLD | NEW |