| 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_headers_stream.h" | 10 #include "net/quic/quic_headers_stream.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 if (!connection_->CanWriteStreamData()) { | 280 if (!connection_->CanWriteStreamData()) { |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 QuicStreamId stream_id = write_blocked_streams_.PopFront(); | 283 QuicStreamId stream_id = write_blocked_streams_.PopFront(); |
| 284 if (stream_id == kCryptoStreamId) { | 284 if (stream_id == kCryptoStreamId) { |
| 285 has_pending_handshake_ = false; // We just popped it. | 285 has_pending_handshake_ = false; // We just popped it. |
| 286 } | 286 } |
| 287 ReliableQuicStream* stream = GetStream(stream_id); | 287 ReliableQuicStream* stream = GetStream(stream_id); |
| 288 if (stream != NULL && !stream->IsFlowControlBlocked()) { | 288 if (stream != NULL && !stream->flow_controller()->IsBlocked()) { |
| 289 // If the stream can't write all bytes, it'll re-add itself to the blocked | 289 // If the stream can't write all bytes, it'll re-add itself to the blocked |
| 290 // list. | 290 // list. |
| 291 stream->OnCanWrite(); | 291 stream->OnCanWrite(); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 bool QuicSession::HasPendingWrites() const { | 296 bool QuicSession::HasPendingWrites() const { |
| 297 return write_blocked_streams_.HasWriteBlockedStreams(); | 297 return write_blocked_streams_.HasWriteBlockedStreams(); |
| 298 } | 298 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 if (new_flow_control_send_window < kDefaultFlowControlSendWindow) { | 382 if (new_flow_control_send_window < kDefaultFlowControlSendWindow) { |
| 383 LOG(DFATAL) | 383 LOG(DFATAL) |
| 384 << "Peer sent us an invalid flow control send window: " | 384 << "Peer sent us an invalid flow control send window: " |
| 385 << new_flow_control_send_window | 385 << new_flow_control_send_window |
| 386 << ", below default: " << kDefaultFlowControlSendWindow; | 386 << ", below default: " << kDefaultFlowControlSendWindow; |
| 387 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_ERROR); | 387 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_ERROR); |
| 388 return; | 388 return; |
| 389 } | 389 } |
| 390 DataStreamMap::iterator it = stream_map_.begin(); | 390 DataStreamMap::iterator it = stream_map_.begin(); |
| 391 while (it != stream_map_.end()) { | 391 while (it != stream_map_.end()) { |
| 392 it->second->UpdateFlowControlSendLimit(new_flow_control_send_window); | 392 it->second->flow_controller()->UpdateSendWindowOffset( |
| 393 new_flow_control_send_window); |
| 393 it++; | 394 it++; |
| 394 } | 395 } |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 | 398 |
| 398 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { | 399 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { |
| 399 switch (event) { | 400 switch (event) { |
| 400 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter | 401 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter |
| 401 // to QuicSession since it is the glue. | 402 // to QuicSession since it is the glue. |
| 402 case ENCRYPTION_FIRST_ESTABLISHED: | 403 case ENCRYPTION_FIRST_ESTABLISHED: |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 552 } |
| 552 | 553 |
| 553 size_t QuicSession::GetNumOpenStreams() const { | 554 size_t QuicSession::GetNumOpenStreams() const { |
| 554 return stream_map_.size() + implicitly_created_streams_.size(); | 555 return stream_map_.size() + implicitly_created_streams_.size(); |
| 555 } | 556 } |
| 556 | 557 |
| 557 void QuicSession::MarkWriteBlocked(QuicStreamId id, QuicPriority priority) { | 558 void QuicSession::MarkWriteBlocked(QuicStreamId id, QuicPriority priority) { |
| 558 #ifndef NDEBUG | 559 #ifndef NDEBUG |
| 559 ReliableQuicStream* stream = GetStream(id); | 560 ReliableQuicStream* stream = GetStream(id); |
| 560 if (stream != NULL) { | 561 if (stream != NULL) { |
| 561 if (stream->IsFlowControlBlocked()) { | 562 if (stream->flow_controller()->IsBlocked()) { |
| 562 LOG(DFATAL) << "Stream " << id << " is flow control blocked."; | 563 LOG(DFATAL) << ENDPOINT << "Stream " << id |
| 564 << " is flow control blocked and write blocked!"; |
| 563 } | 565 } |
| 564 LOG_IF(DFATAL, priority != stream->EffectivePriority()) | 566 LOG_IF(DFATAL, priority != stream->EffectivePriority()) |
| 567 << ENDPOINT << "Stream " << id |
| 565 << "Priorities do not match. Got: " << priority | 568 << "Priorities do not match. Got: " << priority |
| 566 << " Expected: " << stream->EffectivePriority(); | 569 << " Expected: " << stream->EffectivePriority(); |
| 567 } else { | 570 } else { |
| 568 LOG(DFATAL) << "Marking unknown stream " << id << " blocked."; | 571 LOG(DFATAL) << "Marking unknown stream " << id << " blocked."; |
| 569 } | 572 } |
| 570 #endif | 573 #endif |
| 571 | 574 |
| 572 if (id == kCryptoStreamId) { | 575 if (id == kCryptoStreamId) { |
| 573 DCHECK(!has_pending_handshake_); | 576 DCHECK(!has_pending_handshake_); |
| 574 has_pending_handshake_ = true; | 577 has_pending_handshake_ = true; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 589 NOTIMPLEMENTED(); | 592 NOTIMPLEMENTED(); |
| 590 return false; | 593 return false; |
| 591 } | 594 } |
| 592 | 595 |
| 593 void QuicSession::PostProcessAfterData() { | 596 void QuicSession::PostProcessAfterData() { |
| 594 STLDeleteElements(&closed_streams_); | 597 STLDeleteElements(&closed_streams_); |
| 595 closed_streams_.clear(); | 598 closed_streams_.clear(); |
| 596 } | 599 } |
| 597 | 600 |
| 598 } // namespace net | 601 } // namespace net |
| OLD | NEW |