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 <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 return; | 1849 return; |
1850 } | 1850 } |
1851 | 1851 |
1852 if (delta_window_size < 1u) { | 1852 if (delta_window_size < 1u) { |
1853 if (stream_id == kSessionFlowControlStreamId) { | 1853 if (stream_id == kSessionFlowControlStreamId) { |
1854 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); | 1854 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); |
1855 CloseSessionOnError( | 1855 CloseSessionOnError( |
1856 ERR_SPDY_PROTOCOL_ERROR, | 1856 ERR_SPDY_PROTOCOL_ERROR, |
1857 true, | 1857 true, |
1858 "Received WINDOW_UPDATE with an invalid delta_window_size " + | 1858 "Received WINDOW_UPDATE with an invalid delta_window_size " + |
1859 base::UintToString(delta_window_size)); | 1859 base::UintToString(delta_window_size)); |
1860 } else { | 1860 } else { |
1861 ResetStream(stream_id, RST_STREAM_FLOW_CONTROL_ERROR, | 1861 ResetStream(stream_id, RST_STREAM_FLOW_CONTROL_ERROR, |
1862 base::StringPrintf( | 1862 base::StringPrintf( |
1863 "Received WINDOW_UPDATE with an invalid " | 1863 "Received WINDOW_UPDATE with an invalid " |
1864 "delta_window_size %ud", delta_window_size)); | 1864 "delta_window_size %ud", delta_window_size)); |
1865 } | 1865 } |
1866 return; | 1866 return; |
1867 } | 1867 } |
1868 | 1868 |
1869 if (stream_id == kSessionFlowControlStreamId) { | 1869 if (stream_id == kSessionFlowControlStreamId) { |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 DCHECK_GE(delta_window_size, 1); | 2248 DCHECK_GE(delta_window_size, 1); |
2249 | 2249 |
2250 // Check for overflow. | 2250 // Check for overflow. |
2251 int32 max_delta_window_size = kint32max - session_send_window_size_; | 2251 int32 max_delta_window_size = kint32max - session_send_window_size_; |
2252 if (delta_window_size > max_delta_window_size) { | 2252 if (delta_window_size > max_delta_window_size) { |
2253 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); | 2253 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); |
2254 CloseSessionOnError( | 2254 CloseSessionOnError( |
2255 ERR_SPDY_PROTOCOL_ERROR, | 2255 ERR_SPDY_PROTOCOL_ERROR, |
2256 true, | 2256 true, |
2257 "Received WINDOW_UPDATE [delta: " + | 2257 "Received WINDOW_UPDATE [delta: " + |
2258 base::IntToString(delta_window_size) + | 2258 base::IntToString(delta_window_size) + |
2259 "] for session overflows session_send_window_size_ [current: " + | 2259 "] for session overflows session_send_window_size_ [current: " + |
2260 base::IntToString(session_send_window_size_) + "]"); | 2260 base::IntToString(session_send_window_size_) + "]"); |
2261 return; | 2261 return; |
2262 } | 2262 } |
2263 | 2263 |
2264 session_send_window_size_ += delta_window_size; | 2264 session_send_window_size_ += delta_window_size; |
2265 | 2265 |
2266 net_log_.AddEvent( | 2266 net_log_.AddEvent( |
2267 NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, | 2267 NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, |
2268 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 2268 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
2269 delta_window_size, session_send_window_size_)); | 2269 delta_window_size, session_send_window_size_)); |
2270 | 2270 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 | 2330 |
2331 // Since we never decrease the initial receive window size, | 2331 // Since we never decrease the initial receive window size, |
2332 // |delta_window_size| should never cause |recv_window_size_| to go | 2332 // |delta_window_size| should never cause |recv_window_size_| to go |
2333 // negative. If we do, the receive window isn't being respected. | 2333 // negative. If we do, the receive window isn't being respected. |
2334 if (delta_window_size > session_recv_window_size_) { | 2334 if (delta_window_size > session_recv_window_size_) { |
2335 RecordProtocolErrorHistogram(PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION); | 2335 RecordProtocolErrorHistogram(PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION); |
2336 CloseSessionOnError( | 2336 CloseSessionOnError( |
2337 ERR_SPDY_PROTOCOL_ERROR, | 2337 ERR_SPDY_PROTOCOL_ERROR, |
2338 true, | 2338 true, |
2339 "delta_window_size is " + base::IntToString(delta_window_size) + | 2339 "delta_window_size is " + base::IntToString(delta_window_size) + |
2340 " in DecreaseRecvWindowSize, which is larger than the receive " + | 2340 " in DecreaseRecvWindowSize, which is larger than the receive " + |
2341 "window size of " + base::IntToString(session_recv_window_size_)); | 2341 "window size of " + base::IntToString(session_recv_window_size_)); |
2342 return; | 2342 return; |
2343 } | 2343 } |
2344 | 2344 |
2345 session_recv_window_size_ -= delta_window_size; | 2345 session_recv_window_size_ -= delta_window_size; |
2346 net_log_.AddEvent( | 2346 net_log_.AddEvent( |
2347 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, | 2347 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, |
2348 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 2348 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
2349 -delta_window_size, session_recv_window_size_)); | 2349 -delta_window_size, session_recv_window_size_)); |
2350 } | 2350 } |
2351 | 2351 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 if (!queue->empty()) { | 2404 if (!queue->empty()) { |
2405 SpdyStreamId stream_id = queue->front(); | 2405 SpdyStreamId stream_id = queue->front(); |
2406 queue->pop_front(); | 2406 queue->pop_front(); |
2407 return stream_id; | 2407 return stream_id; |
2408 } | 2408 } |
2409 } | 2409 } |
2410 return 0; | 2410 return 0; |
2411 } | 2411 } |
2412 | 2412 |
2413 } // namespace net | 2413 } // namespace net |
OLD | NEW |