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

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

Issue 138503006: Create an interface for explicit notification of Dispatcher about (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_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/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/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 private: 120 private:
121 QuicDispatcher* dispatcher_; 121 QuicDispatcher* dispatcher_;
122 }; 122 };
123 123
124 QuicDispatcher::QuicDispatcher(const QuicConfig& config, 124 QuicDispatcher::QuicDispatcher(const QuicConfig& config,
125 const QuicCryptoServerConfig& crypto_config, 125 const QuicCryptoServerConfig& crypto_config,
126 const QuicVersionVector& supported_versions, 126 const QuicVersionVector& supported_versions,
127 EpollServer* epoll_server) 127 EpollServer* epoll_server)
128 : config_(config), 128 : config_(config),
129 crypto_config_(crypto_config), 129 crypto_config_(crypto_config),
130 time_wait_list_manager_(
131 new QuicTimeWaitListManager(this, epoll_server, supported_versions)),
132 delete_sessions_alarm_(new DeleteSessionsAlarm(this)), 130 delete_sessions_alarm_(new DeleteSessionsAlarm(this)),
133 epoll_server_(epoll_server), 131 epoll_server_(epoll_server),
134 helper_(new QuicEpollConnectionHelper(epoll_server_)), 132 helper_(new QuicEpollConnectionHelper(epoll_server_)),
135 supported_versions_(supported_versions), 133 supported_versions_(supported_versions),
136 current_packet_(NULL), 134 current_packet_(NULL),
137 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true), 135 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true),
138 framer_visitor_(new QuicFramerVisitor(this)) { 136 framer_visitor_(new QuicFramerVisitor(this)) {
139 framer_.set_visitor(framer_visitor_.get()); 137 framer_.set_visitor(framer_visitor_.get());
140 } 138 }
141 139
142 QuicDispatcher::~QuicDispatcher() { 140 QuicDispatcher::~QuicDispatcher() {
143 STLDeleteValues(&session_map_); 141 STLDeleteValues(&session_map_);
144 STLDeleteElements(&closed_session_list_); 142 STLDeleteElements(&closed_session_list_);
145 } 143 }
146 144
147 void QuicDispatcher::Initialize(int fd) { 145 void QuicDispatcher::Initialize(int fd) {
148 DCHECK(writer_ == NULL); 146 DCHECK(writer_ == NULL);
149 writer_.reset(CreateWriterWrapper(CreateWriter(fd))); 147 writer_.reset(CreateWriterWrapper(CreateWriter(fd)));
148 time_wait_list_manager_.reset(
149 new QuicTimeWaitListManager(writer_.get(), this,
150 epoll_server(), supported_versions()));
150 } 151 }
151 152
152 // TODO(fnk): remove the Writer interface implementation in favor of 153 // TODO(fnk): remove the Writer interface implementation in favor of
153 // direct requests for blocked list placement from Connection/Session. 154 // direct requests for blocked list placement from Connection/Session.
154 WriteResult QuicDispatcher::WritePacket(const char* buffer, size_t buf_len, 155 WriteResult QuicDispatcher::WritePacket(const char* buffer, size_t buf_len,
155 const IPAddressNumber& self_address, 156 const IPAddressNumber& self_address,
156 const IPEndPoint& peer_address, 157 const IPEndPoint& peer_address,
157 QuicBlockedWriterInterface* writer) { 158 QuicBlockedWriterInterface* writer) {
158 if (IsWriteBlocked()) { 159 if (IsWriteBlocked()) {
159 write_blocked_list_.insert(make_pair(writer, true)); 160 write_blocked_list_.insert(make_pair(writer, true));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 << QuicUtils::ErrorToString(error); 324 << QuicUtils::ErrorToString(error);
324 325
325 if (closed_session_list_.empty()) { 326 if (closed_session_list_.empty()) {
326 epoll_server_->RegisterAlarmApproximateDelta( 327 epoll_server_->RegisterAlarmApproximateDelta(
327 0, delete_sessions_alarm_.get()); 328 0, delete_sessions_alarm_.get());
328 } 329 }
329 closed_session_list_.push_back(it->second); 330 closed_session_list_.push_back(it->second);
330 CleanUpSession(it); 331 CleanUpSession(it);
331 } 332 }
332 333
334 void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* writer) {
335 DCHECK(writer_->IsWriteBlocked());
336 write_blocked_list_.insert(make_pair(writer, true));
337 }
338
333 QuicSession* QuicDispatcher::CreateQuicSession( 339 QuicSession* QuicDispatcher::CreateQuicSession(
334 QuicGuid guid, 340 QuicGuid guid,
335 const IPEndPoint& server_address, 341 const IPEndPoint& server_address,
336 const IPEndPoint& client_address) { 342 const IPEndPoint& client_address) {
337 QuicServerSession* session = new QuicServerSession( 343 QuicServerSession* session = new QuicServerSession(
338 config_, new QuicConnection(guid, client_address, helper_.get(), this, 344 config_, new QuicConnection(guid, client_address, helper_.get(), this,
339 true, supported_versions_), this); 345 true, supported_versions_), this);
340 session->InitializeSession(crypto_config_); 346 session->InitializeSession(crypto_config_);
341 return session; 347 return session;
342 } 348 }
(...skipping 23 matching lines...) Expand all
366 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromGuid( 372 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromGuid(
367 header.guid)); 373 header.guid));
368 374
369 // Continue parsing the packet to extract the sequence number. Then 375 // Continue parsing the packet to extract the sequence number. Then
370 // send it to the time wait manager in OnUnathenticatedHeader. 376 // send it to the time wait manager in OnUnathenticatedHeader.
371 return true; 377 return true;
372 } 378 }
373 379
374 } // namespace tools 380 } // namespace tools
375 } // namespace net 381 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698