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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/quic/quic_data_writer.cc ('k') | net/quic/quic_end_to_end_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_dispatcher.h" 5 #include "net/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"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 PacketWriterFactory* packet_writer_factory, 180 PacketWriterFactory* packet_writer_factory,
181 QuicConnectionHelperInterface* helper) 181 QuicConnectionHelperInterface* helper)
182 : config_(config), 182 : config_(config),
183 crypto_config_(crypto_config), 183 crypto_config_(crypto_config),
184 helper_(helper), 184 helper_(helper),
185 delete_sessions_alarm_( 185 delete_sessions_alarm_(
186 helper_->CreateAlarm(new DeleteSessionsAlarm(this))), 186 helper_->CreateAlarm(new DeleteSessionsAlarm(this))),
187 packet_writer_factory_(packet_writer_factory), 187 packet_writer_factory_(packet_writer_factory),
188 connection_writer_factory_(this), 188 connection_writer_factory_(this),
189 supported_versions_(supported_versions), 189 supported_versions_(supported_versions),
190 current_packet_(NULL), 190 current_packet_(nullptr),
191 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true), 191 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true),
192 framer_visitor_(new QuicFramerVisitor(this)) { 192 framer_visitor_(new QuicFramerVisitor(this)) {
193 framer_.set_visitor(framer_visitor_.get()); 193 framer_.set_visitor(framer_visitor_.get());
194 } 194 }
195 195
196 QuicDispatcher::~QuicDispatcher() { 196 QuicDispatcher::~QuicDispatcher() {
197 STLDeleteValues(&session_map_); 197 STLDeleteValues(&session_map_);
198 STLDeleteElements(&closed_session_list_); 198 STLDeleteElements(&closed_session_list_);
199 } 199 }
200 200
201 void QuicDispatcher::Initialize(QuicServerPacketWriter* writer) { 201 void QuicDispatcher::Initialize(QuicServerPacketWriter* writer) {
202 DCHECK(writer_ == NULL); 202 DCHECK(writer_ == nullptr);
203 writer_.reset(writer); 203 writer_.reset(writer);
204 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); 204 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager());
205 } 205 }
206 206
207 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address, 207 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address,
208 const IPEndPoint& client_address, 208 const IPEndPoint& client_address,
209 const QuicEncryptedPacket& packet) { 209 const QuicEncryptedPacket& packet) {
210 current_server_address_ = server_address; 210 current_server_address_ = server_address;
211 current_client_address_ = client_address; 211 current_client_address_ = client_address;
212 current_packet_ = &packet; 212 current_packet_ = &packet;
213 // ProcessPacket will cause the packet to be dispatched in 213 // ProcessPacket will cause the packet to be dispatched in
214 // OnUnauthenticatedPublicHeader, or sent to the time wait list manager 214 // OnUnauthenticatedPublicHeader, or sent to the time wait list manager
215 // in OnAuthenticatedHeader. 215 // in OnAuthenticatedHeader.
216 framer_.ProcessPacket(packet); 216 framer_.ProcessPacket(packet);
217 // TODO(rjshade): Return a status describing if/why a packet was dropped, 217 // TODO(rjshade): Return a status describing if/why a packet was dropped,
218 // and log somehow. Maybe expose as a varz. 218 // and log somehow. Maybe expose as a varz.
219 } 219 }
220 220
221 bool QuicDispatcher::OnUnauthenticatedPublicHeader( 221 bool QuicDispatcher::OnUnauthenticatedPublicHeader(
222 const QuicPacketPublicHeader& header) { 222 const QuicPacketPublicHeader& header) {
223 QuicSession* session = NULL; 223 QuicSession* session = nullptr;
224 224
225 QuicConnectionId connection_id = header.connection_id; 225 QuicConnectionId connection_id = header.connection_id;
226 SessionMap::iterator it = session_map_.find(connection_id); 226 SessionMap::iterator it = session_map_.find(connection_id);
227 if (it == session_map_.end()) { 227 if (it == session_map_.end()) {
228 if (header.reset_flag) { 228 if (header.reset_flag) {
229 return false; 229 return false;
230 } 230 }
231 if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { 231 if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) {
232 return HandlePacketForTimeWait(header); 232 return HandlePacketForTimeWait(header);
233 } 233 }
234 234
235 // Ensure the packet has a version negotiation bit set before creating a new 235 // Ensure the packet has a version negotiation bit set before creating a new
236 // session for it. All initial packets for a new connection are required to 236 // session for it. All initial packets for a new connection are required to
237 // have the flag set. Otherwise it may be a stray packet. 237 // have the flag set. Otherwise it may be a stray packet.
238 if (header.version_flag) { 238 if (header.version_flag) {
239 session = CreateQuicSession(connection_id, current_server_address_, 239 session = CreateQuicSession(connection_id, current_server_address_,
240 current_client_address_); 240 current_client_address_);
241 } 241 }
242 242
243 if (session == NULL) { 243 if (session == nullptr) {
244 DVLOG(1) << "Failed to create session for " << connection_id; 244 DVLOG(1) << "Failed to create session for " << connection_id;
245 // Add this connection_id fo the time-wait state, to safely reject future 245 // Add this connection_id fo the time-wait state, to safely reject future
246 // packets. 246 // packets.
247 247
248 if (header.version_flag && 248 if (header.version_flag &&
249 !framer_.IsSupportedVersion(header.versions.front())) { 249 !framer_.IsSupportedVersion(header.versions.front())) {
250 // TODO(ianswett): Produce a no-version version negotiation packet. 250 // TODO(ianswett): Produce a no-version version negotiation packet.
251 return false; 251 return false;
252 } 252 }
253 253
254 // Use the version in the packet if possible, otherwise assume the latest. 254 // Use the version in the packet if possible, otherwise assume the latest.
255 QuicVersion version = header.version_flag ? header.versions.front() : 255 QuicVersion version = header.version_flag ? header.versions.front() :
256 supported_versions_.front(); 256 supported_versions_.front();
257 time_wait_list_manager_->AddConnectionIdToTimeWait( 257 time_wait_list_manager_->AddConnectionIdToTimeWait(connection_id, version,
258 connection_id, version, NULL); 258 nullptr);
259 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); 259 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
260 return HandlePacketForTimeWait(header); 260 return HandlePacketForTimeWait(header);
261 } 261 }
262 DVLOG(1) << "Created new session for " << connection_id; 262 DVLOG(1) << "Created new session for " << connection_id;
263 session_map_.insert(make_pair(connection_id, session)); 263 session_map_.insert(make_pair(connection_id, session));
264 } else { 264 } else {
265 session = it->second; 265 session = it->second;
266 } 266 }
267 267
268 session->connection()->ProcessUdpPacket( 268 session->connection()->ProcessUdpPacket(
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // be parsed correctly. 399 // be parsed correctly.
400 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( 400 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId(
401 header.connection_id)); 401 header.connection_id));
402 402
403 // Continue parsing the packet to extract the sequence number. Then 403 // Continue parsing the packet to extract the sequence number. Then
404 // send it to the time wait manager in OnUnathenticatedHeader. 404 // send it to the time wait manager in OnUnathenticatedHeader.
405 return true; 405 return true;
406 } 406 }
407 407
408 } // namespace net 408 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_data_writer.cc ('k') | net/quic/quic_end_to_end_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698