Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: net/quic/quic_session.cc

Issue 131743009: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use size_t instead of int to fix win_x64 compile error Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_session.h ('k') | net/quic/quic_session_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 virtual void OnSuccessfulVersionNegotiation( 58 virtual void OnSuccessfulVersionNegotiation(
59 const QuicVersion& version) OVERRIDE { 59 const QuicVersion& version) OVERRIDE {
60 session_->OnSuccessfulVersionNegotiation(version); 60 session_->OnSuccessfulVersionNegotiation(version);
61 } 61 }
62 62
63 virtual void OnConfigNegotiated() OVERRIDE { 63 virtual void OnConfigNegotiated() OVERRIDE {
64 session_->OnConfigNegotiated(); 64 session_->OnConfigNegotiated();
65 } 65 }
66 66
67 virtual void OnConnectionClosed(QuicErrorCode error, 67 virtual void OnConnectionClosed(
68 bool from_peer) OVERRIDE { 68 QuicErrorCode error, bool from_peer) OVERRIDE {
69 session_->OnConnectionClosed(error, from_peer); 69 session_->OnConnectionClosed(error, from_peer);
70 // The session will go away, so don't bother with cleanup. 70 // The session will go away, so don't bother with cleanup.
71 } 71 }
72 72
73 virtual void OnWriteBlocked() OVERRIDE {
74 session_->OnWriteBlocked();
75 }
76
73 virtual bool HasPendingHandshake() const OVERRIDE { 77 virtual bool HasPendingHandshake() const OVERRIDE {
74 return session_->HasPendingHandshake(); 78 return session_->HasPendingHandshake();
75 } 79 }
76 80
77 private: 81 private:
78 QuicSession* session_; 82 QuicSession* session_;
79 }; 83 };
80 84
81 QuicSession::QuicSession(QuicConnection* connection, 85 QuicSession::QuicSession(QuicConnection* connection,
82 const QuicConfig& config) 86 const QuicConfig& config)
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 CloseStream(id); 266 CloseStream(id);
263 } 267 }
264 } 268 }
265 } 269 }
266 270
267 bool QuicSession::OnCanWrite() { 271 bool QuicSession::OnCanWrite() {
268 // We latch this here rather than doing a traditional loop, because streams 272 // We latch this here rather than doing a traditional loop, because streams
269 // may be modifying the list as we loop. 273 // may be modifying the list as we loop.
270 int remaining_writes = write_blocked_streams_.NumBlockedStreams(); 274 int remaining_writes = write_blocked_streams_.NumBlockedStreams();
271 275
272 while (!connection_->HasQueuedData() && 276 while (remaining_writes > 0 && connection_->CanWriteStreamData()) {
273 remaining_writes > 0) {
274 DCHECK(write_blocked_streams_.HasWriteBlockedStreams()); 277 DCHECK(write_blocked_streams_.HasWriteBlockedStreams());
275 if (!write_blocked_streams_.HasWriteBlockedStreams()) { 278 if (!write_blocked_streams_.HasWriteBlockedStreams()) {
276 LOG(DFATAL) << "WriteBlockedStream is missing"; 279 LOG(DFATAL) << "WriteBlockedStream is missing";
277 connection_->CloseConnection(QUIC_INTERNAL_ERROR, false); 280 connection_->CloseConnection(QUIC_INTERNAL_ERROR, false);
278 return true; // We have no write blocked streams. 281 return true; // We have no write blocked streams.
279 } 282 }
280 int index = write_blocked_streams_.GetHighestPriorityWriteBlockedList(); 283 QuicStreamId stream_id = write_blocked_streams_.PopFront();
281 QuicStreamId stream_id = write_blocked_streams_.PopFront(index);
282 if (stream_id == kCryptoStreamId) { 284 if (stream_id == kCryptoStreamId) {
283 has_pending_handshake_ = false; // We just popped it. 285 has_pending_handshake_ = false; // We just popped it.
284 } 286 }
285 ReliableQuicStream* stream = GetStream(stream_id); 287 ReliableQuicStream* stream = GetStream(stream_id);
286 if (stream != NULL) { 288 if (stream != NULL) {
287 // 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
288 // list. 290 // list.
289 stream->OnCanWrite(); 291 stream->OnCanWrite();
290 } 292 }
291 --remaining_writes; 293 --remaining_writes;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 return id <= largest_peer_created_stream_id_ && 583 return id <= largest_peer_created_stream_id_ &&
582 implicitly_created_streams_.count(id) == 0; 584 implicitly_created_streams_.count(id) == 0;
583 } 585 }
584 586
585 size_t QuicSession::GetNumOpenStreams() const { 587 size_t QuicSession::GetNumOpenStreams() const {
586 return stream_map_.size() + implicitly_created_streams_.size() - 588 return stream_map_.size() + implicitly_created_streams_.size() -
587 zombie_streams_.size(); 589 zombie_streams_.size();
588 } 590 }
589 591
590 void QuicSession::MarkWriteBlocked(QuicStreamId id, QuicPriority priority) { 592 void QuicSession::MarkWriteBlocked(QuicStreamId id, QuicPriority priority) {
593 #ifndef NDEBUG
594 ReliableQuicStream* stream = GetStream(id);
595 if (stream != NULL) {
596 LOG_IF(DFATAL, priority != stream->EffectivePriority())
597 << "Priorities do not match. Got: " << priority
598 << " Expected: " << stream->EffectivePriority();
599 } else {
600 LOG(DFATAL) << "Marking unknown stream " << id << " blocked.";
601 }
602 #endif
603
591 if (id == kCryptoStreamId) { 604 if (id == kCryptoStreamId) {
592 DCHECK(!has_pending_handshake_); 605 DCHECK(!has_pending_handshake_);
593 has_pending_handshake_ = true; 606 has_pending_handshake_ = true;
594 // TODO(jar): Be sure to use the highest priority for the crypto stream, 607 // TODO(jar): Be sure to use the highest priority for the crypto stream,
595 // perhaps by adding a "special" priority for it that is higher than 608 // perhaps by adding a "special" priority for it that is higher than
596 // kHighestPriority. 609 // kHighestPriority.
597 priority = kHighestPriority; 610 priority = kHighestPriority;
598 } 611 }
599 write_blocked_streams_.PushBack(id, priority); 612 write_blocked_streams_.PushBack(id, priority, connection()->version());
600 } 613 }
601 614
602 bool QuicSession::HasQueuedData() const { 615 bool QuicSession::HasDataToWrite() const {
603 return write_blocked_streams_.NumBlockedStreams() || 616 return write_blocked_streams_.HasWriteBlockedStreams() ||
604 connection_->HasQueuedData(); 617 connection_->HasQueuedData();
605 } 618 }
606 619
607 void QuicSession::MarkDecompressionBlocked(QuicHeaderId header_id, 620 void QuicSession::MarkDecompressionBlocked(QuicHeaderId header_id,
608 QuicStreamId stream_id) { 621 QuicStreamId stream_id) {
609 DCHECK_GE(QUIC_VERSION_12, connection()->version()); 622 DCHECK_GE(QUIC_VERSION_12, connection()->version());
610 decompression_blocked_streams_[header_id] = stream_id; 623 decompression_blocked_streams_[header_id] = stream_id;
611 } 624 }
612 625
613 bool QuicSession::GetSSLInfo(SSLInfo* ssl_info) { 626 bool QuicSession::GetSSLInfo(SSLInfo* ssl_info) {
614 NOTIMPLEMENTED(); 627 NOTIMPLEMENTED();
615 return false; 628 return false;
616 } 629 }
617 630
618 void QuicSession::PostProcessAfterData() { 631 void QuicSession::PostProcessAfterData() {
619 STLDeleteElements(&closed_streams_); 632 STLDeleteElements(&closed_streams_);
620 closed_streams_.clear(); 633 closed_streams_.clear();
621 } 634 }
622 635
623 } // namespace net 636 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.h ('k') | net/quic/quic_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698