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

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

Issue 2326073002: Refactor QuicCryptoServerStream. (Closed)
Patch Set: Created 4 years, 3 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/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 <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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "net/quic/core/crypto/quic_random.h" 13 #include "net/quic/core/crypto/quic_random.h"
14 #include "net/quic/core/quic_bug_tracker.h" 14 #include "net/quic/core/quic_bug_tracker.h"
15 #include "net/quic/core/quic_flags.h" 15 #include "net/quic/core/quic_flags.h"
16 #include "net/quic/core/quic_utils.h" 16 #include "net/quic/core/quic_utils.h"
17 #include "net/tools/quic/quic_simple_server_session.h"
18
17 #include "net/tools/quic/chlo_extractor.h" 19 #include "net/tools/quic/chlo_extractor.h"
18 #include "net/tools/quic/quic_per_connection_packet_writer.h" 20 #include "net/tools/quic/quic_per_connection_packet_writer.h"
19 #include "net/tools/quic/quic_simple_server_session.h" 21 #include "net/tools/quic/quic_simple_server_session.h"
20 #include "net/tools/quic/quic_time_wait_list_manager.h" 22 #include "net/tools/quic/quic_time_wait_list_manager.h"
21 #include "net/tools/quic/stateless_rejector.h" 23 #include "net/tools/quic/stateless_rejector.h"
22 24
23 using base::StringPiece; 25 using base::StringPiece;
24 using std::list; 26 using std::list;
25 using std::string; 27 using std::string;
26 28
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Set as the visitor of |creator_| to collect any generated packets. 150 // Set as the visitor of |creator_| to collect any generated packets.
149 PacketCollector collector_; 151 PacketCollector collector_;
150 QuicPacketCreator creator_; 152 QuicPacketCreator creator_;
151 QuicTimeWaitListManager* time_wait_list_manager_; 153 QuicTimeWaitListManager* time_wait_list_manager_;
152 }; 154 };
153 155
154 // Class which sits between the ChloExtractor and the StatelessRejector 156 // Class which sits between the ChloExtractor and the StatelessRejector
155 // to give the QuicDispatcher a chance to apply policy checks to the CHLO. 157 // to give the QuicDispatcher a chance to apply policy checks to the CHLO.
156 class ChloValidator : public ChloExtractor::Delegate { 158 class ChloValidator : public ChloExtractor::Delegate {
157 public: 159 public:
158 ChloValidator(QuicServerSessionBase::Helper* helper, 160 ChloValidator(QuicCryptoServerStream::Helper* helper,
159 IPEndPoint self_address, 161 IPEndPoint self_address,
160 StatelessRejector* rejector) 162 StatelessRejector* rejector)
161 : helper_(helper), 163 : helper_(helper),
162 self_address_(self_address), 164 self_address_(self_address),
163 rejector_(rejector), 165 rejector_(rejector),
164 can_accept_(false) {} 166 can_accept_(false) {}
165 167
166 // ChloExtractor::Delegate implementation. 168 // ChloExtractor::Delegate implementation.
167 void OnChlo(QuicVersion version, 169 void OnChlo(QuicVersion version,
168 QuicConnectionId connection_id, 170 QuicConnectionId connection_id,
169 const CryptoHandshakeMessage& chlo) override { 171 const CryptoHandshakeMessage& chlo) override {
170 if (helper_->CanAcceptClientHello(chlo, self_address_, &error_details_)) { 172 if (helper_->CanAcceptClientHello(chlo, self_address_, &error_details_)) {
171 can_accept_ = true; 173 can_accept_ = true;
172 rejector_->OnChlo(version, connection_id, 174 rejector_->OnChlo(version, connection_id,
173 helper_->GenerateConnectionIdForReject(connection_id), 175 helper_->GenerateConnectionIdForReject(connection_id),
174 chlo); 176 chlo);
175 } 177 }
176 } 178 }
177 179
178 bool can_accept() const { return can_accept_; } 180 bool can_accept() const { return can_accept_; }
179 181
180 const string& error_details() const { return error_details_; } 182 const string& error_details() const { return error_details_; }
181 183
182 private: 184 private:
183 QuicServerSessionBase::Helper* helper_; // Unowned. 185 QuicCryptoServerStream::Helper* helper_; // Unowned.
184 IPEndPoint self_address_; 186 IPEndPoint self_address_;
185 StatelessRejector* rejector_; // Unowned. 187 StatelessRejector* rejector_; // Unowned.
186 bool can_accept_; 188 bool can_accept_;
187 string error_details_; 189 string error_details_;
188 }; 190 };
189 191
190 } // namespace 192 } // namespace
191 193
192 QuicDispatcher::QuicDispatcher( 194 QuicDispatcher::QuicDispatcher(
193 const QuicConfig& config, 195 const QuicConfig& config,
194 const QuicCryptoServerConfig* crypto_config, 196 const QuicCryptoServerConfig* crypto_config,
195 QuicVersionManager* version_manager, 197 QuicVersionManager* version_manager,
196 std::unique_ptr<QuicConnectionHelperInterface> helper, 198 std::unique_ptr<QuicConnectionHelperInterface> helper,
197 std::unique_ptr<QuicServerSessionBase::Helper> session_helper, 199 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
198 std::unique_ptr<QuicAlarmFactory> alarm_factory) 200 std::unique_ptr<QuicAlarmFactory> alarm_factory)
199 : config_(config), 201 : config_(config),
200 crypto_config_(crypto_config), 202 crypto_config_(crypto_config),
201 compressed_certs_cache_( 203 compressed_certs_cache_(
202 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), 204 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize),
203 helper_(std::move(helper)), 205 helper_(std::move(helper)),
204 session_helper_(std::move(session_helper)), 206 session_helper_(std::move(session_helper)),
205 alarm_factory_(std::move(alarm_factory)), 207 alarm_factory_(std::move(alarm_factory)),
206 delete_sessions_alarm_( 208 delete_sessions_alarm_(
207 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))), 209 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))),
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 void QuicDispatcher::DeliverPacketsToSession( 906 void QuicDispatcher::DeliverPacketsToSession(
905 const std::list<BufferedPacket>& packets, 907 const std::list<BufferedPacket>& packets,
906 QuicServerSessionBase* session) { 908 QuicServerSessionBase* session) {
907 for (const BufferedPacket& packet : packets) { 909 for (const BufferedPacket& packet : packets) {
908 session->ProcessUdpPacket(packet.server_address, packet.client_address, 910 session->ProcessUdpPacket(packet.server_address, packet.client_address,
909 *(packet.packet)); 911 *(packet.packet));
910 } 912 }
911 } 913 }
912 914
913 } // namespace net 915 } // 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