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

Side by Side Diff: net/tools/quic/quic_dispatcher.cc

Issue 2464603002: Break reliance of QuicDispatcher on QuicServerSessionBase (Closed)
Patch Set: Updated patchset dependency Created 4 years, 1 month 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
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/tools/quic/quic_dispatcher.h" 5 #include "net/tools/quic/quic_dispatcher.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 blocked_writer->OnCanWrite(); 468 blocked_writer->OnCanWrite();
469 } 469 }
470 } 470 }
471 471
472 bool QuicDispatcher::HasPendingWrites() const { 472 bool QuicDispatcher::HasPendingWrites() const {
473 return !write_blocked_list_.empty(); 473 return !write_blocked_list_.empty();
474 } 474 }
475 475
476 void QuicDispatcher::Shutdown() { 476 void QuicDispatcher::Shutdown() {
477 while (!session_map_.empty()) { 477 while (!session_map_.empty()) {
478 QuicServerSessionBase* session = session_map_.begin()->second.get(); 478 QuicSession* session = session_map_.begin()->second.get();
479 session->connection()->CloseConnection( 479 session->connection()->CloseConnection(
480 QUIC_PEER_GOING_AWAY, "Server shutdown imminent", 480 QUIC_PEER_GOING_AWAY, "Server shutdown imminent",
481 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 481 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
482 // Validate that the session removes itself from the session map on close. 482 // Validate that the session removes itself from the session map on close.
483 DCHECK(session_map_.empty() || 483 DCHECK(session_map_.empty() ||
484 session_map_.begin()->second.get() != session); 484 session_map_.begin()->second.get() != session);
485 } 485 }
486 DeleteSessions(); 486 DeleteSessions();
487 } 487 }
488 488
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 // Reset the counter before starting creating connections. 647 // Reset the counter before starting creating connections.
648 new_sessions_allowed_per_event_loop_ = max_connections_to_create; 648 new_sessions_allowed_per_event_loop_ = max_connections_to_create;
649 for (; new_sessions_allowed_per_event_loop_ > 0; 649 for (; new_sessions_allowed_per_event_loop_ > 0;
650 --new_sessions_allowed_per_event_loop_) { 650 --new_sessions_allowed_per_event_loop_) {
651 QuicConnectionId connection_id; 651 QuicConnectionId connection_id;
652 list<BufferedPacket> packets = 652 list<BufferedPacket> packets =
653 buffered_packets_.DeliverPacketsForNextConnection(&connection_id); 653 buffered_packets_.DeliverPacketsForNextConnection(&connection_id);
654 if (packets.empty()) { 654 if (packets.empty()) {
655 return; 655 return;
656 } 656 }
657 QuicServerSessionBase* session = 657 QuicSession* session =
658 CreateQuicSession(connection_id, packets.front().client_address); 658 CreateQuicSession(connection_id, packets.front().client_address);
659 DVLOG(1) << "Created new session for " << connection_id; 659 DVLOG(1) << "Created new session for " << connection_id;
660 session_map_.insert( 660 session_map_.insert(
661 std::make_pair(connection_id, base::WrapUnique(session))); 661 std::make_pair(connection_id, base::WrapUnique(session)));
662 DeliverPacketsToSession(packets, session); 662 DeliverPacketsToSession(packets, session);
663 } 663 }
664 } 664 }
665 665
666 bool QuicDispatcher::HasChlosBuffered() const { 666 bool QuicDispatcher::HasChlosBuffered() const {
667 return buffered_packets_.HasChlosBuffered(); 667 return buffered_packets_.HasChlosBuffered();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if (rs != EnqueuePacketResult::SUCCESS) { 744 if (rs != EnqueuePacketResult::SUCCESS) {
745 OnBufferPacketFailure(rs, current_connection_id_); 745 OnBufferPacketFailure(rs, current_connection_id_);
746 } else if (!FLAGS_quic_create_session_after_insertion && 746 } else if (!FLAGS_quic_create_session_after_insertion &&
747 is_new_connection) { 747 is_new_connection) {
748 ShouldCreateOrBufferPacketForConnection(current_connection_id_); 748 ShouldCreateOrBufferPacketForConnection(current_connection_id_);
749 } 749 }
750 } 750 }
751 return; 751 return;
752 } 752 }
753 // Creates a new session and process all buffered packets for this connection. 753 // Creates a new session and process all buffered packets for this connection.
754 QuicServerSessionBase* session = 754 QuicSession* session =
755 CreateQuicSession(current_connection_id_, current_client_address_); 755 CreateQuicSession(current_connection_id_, current_client_address_);
756 DVLOG(1) << "Created new session for " << current_connection_id_; 756 DVLOG(1) << "Created new session for " << current_connection_id_;
757 session_map_.insert( 757 session_map_.insert(
758 std::make_pair(current_connection_id_, base::WrapUnique(session))); 758 std::make_pair(current_connection_id_, base::WrapUnique(session)));
759 std::list<BufferedPacket> packets = 759 std::list<BufferedPacket> packets =
760 buffered_packets_.DeliverPackets(current_connection_id_); 760 buffered_packets_.DeliverPackets(current_connection_id_);
761 // Check if CHLO is the first packet arrived on this connection. 761 // Check if CHLO is the first packet arrived on this connection.
762 if (!FLAGS_quic_create_session_after_insertion && 762 if (!FLAGS_quic_create_session_after_insertion &&
763 FLAGS_quic_buffer_packet_till_chlo && packets.empty()) { 763 FLAGS_quic_buffer_packet_till_chlo && packets.empty()) {
764 ShouldCreateOrBufferPacketForConnection(current_connection_id_); 764 ShouldCreateOrBufferPacketForConnection(current_connection_id_);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 } 998 }
999 ProcessUnauthenticatedHeaderFate(fate, rejector->connection_id(), 999 ProcessUnauthenticatedHeaderFate(fate, rejector->connection_id(),
1000 packet_number); 1000 packet_number);
1001 } 1001 }
1002 1002
1003 const QuicVersionVector& QuicDispatcher::GetSupportedVersions() { 1003 const QuicVersionVector& QuicDispatcher::GetSupportedVersions() {
1004 return version_manager_->GetSupportedVersions(); 1004 return version_manager_->GetSupportedVersions();
1005 } 1005 }
1006 1006
1007 void QuicDispatcher::DeliverPacketsToSession( 1007 void QuicDispatcher::DeliverPacketsToSession(
1008 const std::list<BufferedPacket>& packets, 1008 const list<BufferedPacket>& packets,
1009 QuicServerSessionBase* session) { 1009 QuicSession* session) {
1010 for (const BufferedPacket& packet : packets) { 1010 for (const BufferedPacket& packet : packets) {
1011 session->ProcessUdpPacket(packet.server_address, packet.client_address, 1011 session->ProcessUdpPacket(packet.server_address, packet.client_address,
1012 *(packet.packet)); 1012 *(packet.packet));
1013 } 1013 }
1014 } 1014 }
1015 1015
1016 } // namespace net 1016 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/test_tools/mock_quic_server_session_visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698