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/quic/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/crypto/proof_verifier.h" | 8 #include "net/quic/crypto/proof_verifier.h" |
9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
10 #include "net/quic/quic_flow_controller.h" | 10 #include "net/quic/quic_flow_controller.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 it->second->OnConnectionClosed(error, from_peer); | 229 it->second->OnConnectionClosed(error, from_peer); |
230 // The stream should call CloseStream as part of OnConnectionClosed. | 230 // The stream should call CloseStream as part of OnConnectionClosed. |
231 if (stream_map_.find(id) != stream_map_.end()) { | 231 if (stream_map_.find(id) != stream_map_.end()) { |
232 LOG(DFATAL) << ENDPOINT | 232 LOG(DFATAL) << ENDPOINT |
233 << "Stream failed to close under OnConnectionClosed"; | 233 << "Stream failed to close under OnConnectionClosed"; |
234 CloseStream(id); | 234 CloseStream(id); |
235 } | 235 } |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
| 239 void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion& version) { |
| 240 headers_stream_->OnSuccessfulVersionNegotiation(version); |
| 241 } |
| 242 |
239 void QuicSession::OnWindowUpdateFrames( | 243 void QuicSession::OnWindowUpdateFrames( |
240 const vector<QuicWindowUpdateFrame>& frames) { | 244 const vector<QuicWindowUpdateFrame>& frames) { |
241 bool connection_window_updated = false; | 245 bool connection_window_updated = false; |
242 for (size_t i = 0; i < frames.size(); ++i) { | 246 for (size_t i = 0; i < frames.size(); ++i) { |
243 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't | 247 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't |
244 // assume that it still exists. | 248 // assume that it still exists. |
245 QuicStreamId stream_id = frames[i].stream_id; | 249 QuicStreamId stream_id = frames[i].stream_id; |
246 if (stream_id == kConnectionLevelId) { | 250 if (stream_id == kConnectionLevelId) { |
247 // This is a window update that applies to the connection, rather than an | 251 // This is a window update that applies to the connection, rather than an |
248 // individual stream. | 252 // individual stream. |
249 DVLOG(1) << ENDPOINT | 253 DVLOG(1) << ENDPOINT |
250 << "Received connection level flow control window update with " | 254 << "Received connection level flow control window update with " |
251 "byte offset: " << frames[i].byte_offset; | 255 "byte offset: " << frames[i].byte_offset; |
252 if (flow_controller_->UpdateSendWindowOffset(frames[i].byte_offset)) { | 256 if (flow_controller_->UpdateSendWindowOffset(frames[i].byte_offset)) { |
253 connection_window_updated = true; | 257 connection_window_updated = true; |
254 } | 258 } |
255 continue; | 259 continue; |
256 } | 260 } |
257 | 261 |
258 if (connection_->version() < QUIC_VERSION_21 && | |
259 (stream_id == kCryptoStreamId || stream_id == kHeadersStreamId)) { | |
260 DLOG(DFATAL) << "WindowUpdate for stream " << stream_id << " in version " | |
261 << QuicVersionToString(connection_->version()); | |
262 return; | |
263 } | |
264 | |
265 ReliableQuicStream* stream = GetStream(stream_id); | 262 ReliableQuicStream* stream = GetStream(stream_id); |
266 if (stream) { | 263 if (stream) { |
267 stream->OnWindowUpdateFrame(frames[i]); | 264 stream->OnWindowUpdateFrame(frames[i]); |
268 } | 265 } |
269 } | 266 } |
270 | 267 |
271 // Connection level flow control window has increased, so blocked streams can | 268 // Connection level flow control window has increased, so blocked streams can |
272 // write again. | 269 // write again. |
273 if (connection_window_updated) { | 270 if (connection_window_updated) { |
274 OnCanWrite(); | 271 OnCanWrite(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 FecProtection fec_protection, | 356 FecProtection fec_protection, |
360 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { | 357 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { |
361 return connection_->SendStreamData(id, data, offset, fin, fec_protection, | 358 return connection_->SendStreamData(id, data, offset, fin, fec_protection, |
362 ack_notifier_delegate); | 359 ack_notifier_delegate); |
363 } | 360 } |
364 | 361 |
365 size_t QuicSession::WriteHeaders( | 362 size_t QuicSession::WriteHeaders( |
366 QuicStreamId id, | 363 QuicStreamId id, |
367 const SpdyHeaderBlock& headers, | 364 const SpdyHeaderBlock& headers, |
368 bool fin, | 365 bool fin, |
| 366 QuicPriority priority, |
369 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { | 367 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { |
370 return headers_stream_->WriteHeaders(id, headers, fin, ack_notifier_delegate); | 368 return headers_stream_->WriteHeaders(id, headers, fin, priority, |
| 369 ack_notifier_delegate); |
371 } | 370 } |
372 | 371 |
373 void QuicSession::SendRstStream(QuicStreamId id, | 372 void QuicSession::SendRstStream(QuicStreamId id, |
374 QuicRstStreamErrorCode error, | 373 QuicRstStreamErrorCode error, |
375 QuicStreamOffset bytes_written) { | 374 QuicStreamOffset bytes_written) { |
376 if (connection()->connected()) { | 375 if (connection()->connected()) { |
377 // Only send a RST_STREAM frame if still connected. | 376 // Only send a RST_STREAM frame if still connected. |
378 connection_->SendRstStream(id, error, bytes_written); | 377 connection_->SendRstStream(id, error, bytes_written); |
379 } | 378 } |
380 CloseStreamInner(id, true); | 379 CloseStreamInner(id, true); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 LOG(ERROR) << "Peer sent us an invalid stream flow control send window: " | 490 LOG(ERROR) << "Peer sent us an invalid stream flow control send window: " |
492 << new_window | 491 << new_window |
493 << ", below default: " << kMinimumFlowControlSendWindow; | 492 << ", below default: " << kMinimumFlowControlSendWindow; |
494 if (connection_->connected()) { | 493 if (connection_->connected()) { |
495 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 494 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
496 } | 495 } |
497 return; | 496 return; |
498 } | 497 } |
499 | 498 |
500 // Inform all existing streams about the new window. | 499 // Inform all existing streams about the new window. |
501 if (connection_->version() >= QUIC_VERSION_21) { | 500 GetCryptoStream()->UpdateSendWindowOffset(new_window); |
502 GetCryptoStream()->UpdateSendWindowOffset(new_window); | 501 headers_stream_->UpdateSendWindowOffset(new_window); |
503 headers_stream_->UpdateSendWindowOffset(new_window); | |
504 } | |
505 for (DataStreamMap::iterator it = stream_map_.begin(); | 502 for (DataStreamMap::iterator it = stream_map_.begin(); |
506 it != stream_map_.end(); ++it) { | 503 it != stream_map_.end(); ++it) { |
507 it->second->UpdateSendWindowOffset(new_window); | 504 it->second->UpdateSendWindowOffset(new_window); |
508 } | 505 } |
509 } | 506 } |
510 | 507 |
511 void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window) { | 508 void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window) { |
512 if (new_window < kMinimumFlowControlSendWindow) { | 509 if (new_window < kMinimumFlowControlSendWindow) { |
513 LOG(ERROR) << "Peer sent us an invalid session flow control send window: " | 510 LOG(ERROR) << "Peer sent us an invalid session flow control send window: " |
514 << new_window | 511 << new_window |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 for (DataStreamMap::iterator it = stream_map_.begin(); | 743 for (DataStreamMap::iterator it = stream_map_.begin(); |
747 it != stream_map_.end(); ++it) { | 744 it != stream_map_.end(); ++it) { |
748 if (it->second->flow_controller()->IsBlocked()) { | 745 if (it->second->flow_controller()->IsBlocked()) { |
749 return true; | 746 return true; |
750 } | 747 } |
751 } | 748 } |
752 return false; | 749 return false; |
753 } | 750 } |
754 | 751 |
755 } // namespace net | 752 } // namespace net |
OLD | NEW |