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

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

Issue 1031243002: Unify the QUIC dispatcher and make the QuicServer work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix iOS Created 5 years, 9 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
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 <errno.h> 7 #include <errno.h>
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"
11 #include "net/quic/quic_blocked_writer_interface.h" 11 #include "net/quic/quic_blocked_writer_interface.h"
12 #include "net/quic/quic_flags.h" 12 #include "net/quic/quic_flags.h"
13 #include "net/quic/quic_utils.h" 13 #include "net/quic/quic_utils.h"
14 #include "net/tools/epoll_server/epoll_server.h"
15 #include "net/tools/quic/quic_default_packet_writer.h"
16 #include "net/tools/quic/quic_epoll_connection_helper.h"
17 #include "net/tools/quic/quic_per_connection_packet_writer.h" 14 #include "net/tools/quic/quic_per_connection_packet_writer.h"
18 #include "net/tools/quic/quic_socket_utils.h" 15 #include "net/tools/quic/quic_socket_utils.h"
19 #include "net/tools/quic/quic_time_wait_list_manager.h" 16 #include "net/tools/quic/quic_time_wait_list_manager.h"
20 17
21 namespace net { 18 namespace net {
22 19
23 namespace tools { 20 namespace tools {
24 21
25 using base::StringPiece; 22 using base::StringPiece;
26 23
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 Perspective::IS_SERVER), 183 Perspective::IS_SERVER),
187 framer_visitor_(new QuicFramerVisitor(this)) { 184 framer_visitor_(new QuicFramerVisitor(this)) {
188 framer_.set_visitor(framer_visitor_.get()); 185 framer_.set_visitor(framer_visitor_.get());
189 } 186 }
190 187
191 QuicDispatcher::~QuicDispatcher() { 188 QuicDispatcher::~QuicDispatcher() {
192 STLDeleteValues(&session_map_); 189 STLDeleteValues(&session_map_);
193 STLDeleteElements(&closed_session_list_); 190 STLDeleteElements(&closed_session_list_);
194 } 191 }
195 192
196 void QuicDispatcher::Initialize(int fd) { 193 void QuicDispatcher::InitializeWithWriter(QuicPacketWriter* writer) {
197 DCHECK(writer_ == nullptr); 194 DCHECK(writer_ == nullptr);
198 writer_.reset(CreateWriter(fd)); 195 writer_.reset(writer);
199 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); 196 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager());
200 } 197 }
201 198
202 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address, 199 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address,
203 const IPEndPoint& client_address, 200 const IPEndPoint& client_address,
204 const QuicEncryptedPacket& packet) { 201 const QuicEncryptedPacket& packet) {
205 current_server_address_ = server_address; 202 current_server_address_ = server_address;
206 current_client_address_ = client_address; 203 current_client_address_ = client_address;
207 current_packet_ = &packet; 204 current_packet_ = &packet;
208 // ProcessPacket will cause the packet to be dispatched in 205 // ProcessPacket will cause the packet to be dispatched in
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 void QuicDispatcher::OnConnectionAddedToTimeWaitList( 391 void QuicDispatcher::OnConnectionAddedToTimeWaitList(
395 QuicConnectionId connection_id) { 392 QuicConnectionId connection_id) {
396 DVLOG(1) << "Connection " << connection_id << " added to time wait list."; 393 DVLOG(1) << "Connection " << connection_id << " added to time wait list.";
397 } 394 }
398 395
399 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( 396 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList(
400 QuicConnectionId connection_id) { 397 QuicConnectionId connection_id) {
401 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; 398 DVLOG(1) << "Connection " << connection_id << " removed from time wait list.";
402 } 399 }
403 400
404 QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) {
405 return new QuicDefaultPacketWriter(fd);
406 }
407
408 QuicServerSession* QuicDispatcher::CreateQuicSession( 401 QuicServerSession* QuicDispatcher::CreateQuicSession(
409 QuicConnectionId connection_id, 402 QuicConnectionId connection_id,
410 const IPEndPoint& server_address, 403 const IPEndPoint& server_address,
411 const IPEndPoint& client_address) { 404 const IPEndPoint& client_address) {
412 // The QuicServerSession takes ownership of |connection| below. 405 // The QuicServerSession takes ownership of |connection| below.
413 QuicConnection* connection = new QuicConnection( 406 QuicConnection* connection = new QuicConnection(
414 connection_id, client_address, helper_.get(), connection_writer_factory_, 407 connection_id, client_address, helper_.get(), connection_writer_factory_,
415 /* owns_writer= */ true, Perspective::IS_SERVER, 408 /* owns_writer= */ true, Perspective::IS_SERVER,
416 crypto_config_.HasProofSource(), supported_versions_); 409 crypto_config_.HasProofSource(), supported_versions_);
417 410
(...skipping 19 matching lines...) Expand all
437 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( 430 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId(
438 header.connection_id)); 431 header.connection_id));
439 432
440 // Continue parsing the packet to extract the sequence number. Then 433 // Continue parsing the packet to extract the sequence number. Then
441 // send it to the time wait manager in OnUnathenticatedHeader. 434 // send it to the time wait manager in OnUnathenticatedHeader.
442 return true; 435 return true;
443 } 436 }
444 437
445 } // namespace tools 438 } // namespace tools
446 } // namespace net 439 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698