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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 | 57 |
58 // Minimum seconds that unclaimed pushed streams will be kept in memory. | 58 // Minimum seconds that unclaimed pushed streams will be kept in memory. |
59 const int kMinPushedStreamLifetimeSeconds = 300; | 59 const int kMinPushedStreamLifetimeSeconds = 300; |
60 | 60 |
61 scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue( | 61 scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue( |
62 const SpdyHeaderBlock& headers, | 62 const SpdyHeaderBlock& headers, |
63 net::NetLog::LogLevel log_level) { | 63 net::NetLog::LogLevel log_level) { |
64 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); | 64 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); |
65 for (SpdyHeaderBlock::const_iterator it = headers.begin(); | 65 for (SpdyHeaderBlock::const_iterator it = headers.begin(); |
66 it != headers.end(); ++it) { | 66 it != headers.end(); ++it) { |
67 headers_list->AppendString( | 67 headers_list->AppendString(std::string(it->first).append(": ").append( |
68 it->first + ": " + | 68 ElideHeaderValueForNetLog(log_level, it->first, it->second))); |
69 ElideHeaderValueForNetLog(log_level, it->first, it->second)); | |
70 } | 69 } |
71 return headers_list.Pass(); | 70 return headers_list.Pass(); |
72 } | 71 } |
73 | 72 |
74 base::Value* NetLogSpdySynStreamSentCallback(const SpdyHeaderBlock* headers, | 73 base::Value* NetLogSpdySynStreamSentCallback(const SpdyHeaderBlock* headers, |
75 bool fin, | 74 bool fin, |
76 bool unidirectional, | 75 bool unidirectional, |
77 SpdyPriority spdy_priority, | 76 SpdyPriority spdy_priority, |
78 SpdyStreamId stream_id, | 77 SpdyStreamId stream_id, |
79 NetLog::LogLevel log_level) { | 78 NetLog::LogLevel log_level) { |
(...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2528 LOG(WARNING) << "Received WINDOW_UPDATE for session when " | 2527 LOG(WARNING) << "Received WINDOW_UPDATE for session when " |
2529 << "session flow control is not turned on"; | 2528 << "session flow control is not turned on"; |
2530 // TODO(akalin): Record an error and close the session. | 2529 // TODO(akalin): Record an error and close the session. |
2531 return; | 2530 return; |
2532 } | 2531 } |
2533 | 2532 |
2534 if (delta_window_size < 1u) { | 2533 if (delta_window_size < 1u) { |
2535 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); | 2534 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); |
2536 DoDrainSession( | 2535 DoDrainSession( |
2537 ERR_SPDY_PROTOCOL_ERROR, | 2536 ERR_SPDY_PROTOCOL_ERROR, |
2538 "Received WINDOW_UPDATE with an invalid delta_window_size " + | 2537 std::string( |
2539 base::UintToString(delta_window_size)); | 2538 "Received WINDOW_UPDATE with an invalid delta_window_size ") |
2539 .append(base::UintToString(delta_window_size))); | |
mmenke
2015/03/09 20:21:58
This could just be:
base::StringPrintf("Received.
| |
2540 return; | 2540 return; |
2541 } | 2541 } |
2542 | 2542 |
2543 IncreaseSendWindowSize(static_cast<int32>(delta_window_size)); | 2543 IncreaseSendWindowSize(static_cast<int32>(delta_window_size)); |
2544 } else { | 2544 } else { |
2545 // WINDOW_UPDATE for a stream. | 2545 // WINDOW_UPDATE for a stream. |
2546 if (flow_control_state_ < FLOW_CONTROL_STREAM) { | 2546 if (flow_control_state_ < FLOW_CONTROL_STREAM) { |
2547 // TODO(akalin): Record an error and close the session. | 2547 // TODO(akalin): Record an error and close the session. |
2548 LOG(WARNING) << "Received WINDOW_UPDATE for stream " << stream_id | 2548 LOG(WARNING) << "Received WINDOW_UPDATE for stream " << stream_id |
2549 << " when flow control is not turned on"; | 2549 << " when flow control is not turned on"; |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3140 | 3140 |
3141 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3141 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
3142 DCHECK_GE(delta_window_size, 1); | 3142 DCHECK_GE(delta_window_size, 1); |
3143 | 3143 |
3144 // Check for overflow. | 3144 // Check for overflow. |
3145 int32 max_delta_window_size = kint32max - session_send_window_size_; | 3145 int32 max_delta_window_size = kint32max - session_send_window_size_; |
3146 if (delta_window_size > max_delta_window_size) { | 3146 if (delta_window_size > max_delta_window_size) { |
3147 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); | 3147 RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE); |
3148 DoDrainSession( | 3148 DoDrainSession( |
3149 ERR_SPDY_PROTOCOL_ERROR, | 3149 ERR_SPDY_PROTOCOL_ERROR, |
3150 "Received WINDOW_UPDATE [delta: " + | 3150 std::string("Received WINDOW_UPDATE [delta: ") |
3151 base::IntToString(delta_window_size) + | 3151 .append(base::IntToString(delta_window_size)) |
3152 "] for session overflows session_send_window_size_ [current: " + | 3152 .append( |
3153 base::IntToString(session_send_window_size_) + "]"); | 3153 "] for session overflows session_send_window_size_ [current: ") |
3154 .append(base::IntToString(session_send_window_size_)) | |
3155 .append("]")); | |
3154 return; | 3156 return; |
3155 } | 3157 } |
3156 | 3158 |
3157 session_send_window_size_ += delta_window_size; | 3159 session_send_window_size_ += delta_window_size; |
3158 | 3160 |
3159 net_log_.AddEvent( | 3161 net_log_.AddEvent( |
3160 NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, | 3162 NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, |
3161 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3163 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
3162 delta_window_size, session_send_window_size_)); | 3164 delta_window_size, session_send_window_size_)); |
3163 | 3165 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3225 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { | 3227 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { |
3226 CHECK(in_io_loop_); | 3228 CHECK(in_io_loop_); |
3227 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3229 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
3228 DCHECK_GE(delta_window_size, 1); | 3230 DCHECK_GE(delta_window_size, 1); |
3229 | 3231 |
3230 // Since we never decrease the initial receive window size, | 3232 // Since we never decrease the initial receive window size, |
3231 // |delta_window_size| should never cause |recv_window_size_| to go | 3233 // |delta_window_size| should never cause |recv_window_size_| to go |
3232 // negative. If we do, the receive window isn't being respected. | 3234 // negative. If we do, the receive window isn't being respected. |
3233 if (delta_window_size > session_recv_window_size_) { | 3235 if (delta_window_size > session_recv_window_size_) { |
3234 RecordProtocolErrorHistogram(PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION); | 3236 RecordProtocolErrorHistogram(PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION); |
3235 DoDrainSession( | 3237 DoDrainSession(ERR_SPDY_FLOW_CONTROL_ERROR, |
3236 ERR_SPDY_FLOW_CONTROL_ERROR, | 3238 std::string("delta_window_size is ") |
3237 "delta_window_size is " + base::IntToString(delta_window_size) + | 3239 .append(base::IntToString(delta_window_size)) |
3238 " in DecreaseRecvWindowSize, which is larger than the receive " + | 3240 .append( |
3239 "window size of " + base::IntToString(session_recv_window_size_)); | 3241 " in DecreaseRecvWindowSize, which is larger than " |
3242 "the receive window size of ") | |
3243 .append(base::IntToString(session_recv_window_size_))); | |
3240 return; | 3244 return; |
3241 } | 3245 } |
3242 | 3246 |
3243 session_recv_window_size_ -= delta_window_size; | 3247 session_recv_window_size_ -= delta_window_size; |
3244 net_log_.AddEvent( | 3248 net_log_.AddEvent( |
3245 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, | 3249 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, |
3246 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3250 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
3247 -delta_window_size, session_recv_window_size_)); | 3251 -delta_window_size, session_recv_window_size_)); |
3248 } | 3252 } |
3249 | 3253 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3291 if (!queue->empty()) { | 3295 if (!queue->empty()) { |
3292 SpdyStreamId stream_id = queue->front(); | 3296 SpdyStreamId stream_id = queue->front(); |
3293 queue->pop_front(); | 3297 queue->pop_front(); |
3294 return stream_id; | 3298 return stream_id; |
3295 } | 3299 } |
3296 } | 3300 } |
3297 return 0; | 3301 return 0; |
3298 } | 3302 } |
3299 | 3303 |
3300 } // namespace net | 3304 } // namespace net |
OLD | NEW |