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

Side by Side Diff: net/tools/quic/test_tools/quic_test_server.cc

Issue 2322233004: Landing Recent QUIC changes until Sun Sep 4 03:41:00 (Closed)
Patch Set: Remove simulation files from the build. 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/test_tools/quic_test_server.h ('k') | no next file » | 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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/test_tools/quic_test_server.h" 5 #include "net/tools/quic/test_tools/quic_test_server.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "net/base/ip_endpoint.h" 11 #include "net/base/ip_endpoint.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/quic/chromium/quic_chromium_connection_helper.h" 13 #include "net/quic/chromium/quic_chromium_connection_helper.h"
14 #include "net/quic/core/crypto/crypto_handshake.h" 14 #include "net/quic/core/crypto/crypto_handshake.h"
15 #include "net/quic/core/crypto/quic_crypto_server_config.h" 15 #include "net/quic/core/crypto/quic_crypto_server_config.h"
16 #include "net/quic/core/crypto/quic_random.h" 16 #include "net/quic/core/crypto/quic_random.h"
17 #include "net/quic/core/quic_config.h" 17 #include "net/quic/core/quic_config.h"
18 #include "net/quic/core/quic_connection.h" 18 #include "net/quic/core/quic_connection.h"
19 #include "net/quic/core/quic_packet_writer.h" 19 #include "net/quic/core/quic_packet_writer.h"
20 #include "net/quic/core/quic_protocol.h" 20 #include "net/quic/core/quic_protocol.h"
21 #include "net/tools/quic/quic_epoll_alarm_factory.h" 21 #include "net/tools/quic/quic_epoll_alarm_factory.h"
22 #include "net/tools/quic/quic_epoll_connection_helper.h" 22 #include "net/tools/quic/quic_epoll_connection_helper.h"
23 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h"
23 #include "net/tools/quic/quic_simple_dispatcher.h" 24 #include "net/tools/quic/quic_simple_dispatcher.h"
24 #include "net/tools/quic/quic_simple_server_session.h" 25 #include "net/tools/quic/quic_simple_server_session.h"
25 #include "net/tools/quic/quic_simple_server_session_helper.h"
26 #include "net/tools/quic/quic_simple_server_stream.h" 26 #include "net/tools/quic/quic_simple_server_stream.h"
27 27
28 namespace net { 28 namespace net {
29 namespace test { 29 namespace test {
30 30
31 class CustomStreamSession : public QuicSimpleServerSession { 31 class CustomStreamSession : public QuicSimpleServerSession {
32 public: 32 public:
33 CustomStreamSession( 33 CustomStreamSession(
34 const QuicConfig& config, 34 const QuicConfig& config,
35 QuicConnection* connection, 35 QuicConnection* connection,
36 QuicServerSessionBase::Visitor* visitor, 36 QuicServerSessionBase::Visitor* visitor,
37 QuicServerSessionBase::Helper* helper, 37 QuicCryptoServerStream::Helper* helper,
38 const QuicCryptoServerConfig* crypto_config, 38 const QuicCryptoServerConfig* crypto_config,
39 QuicCompressedCertsCache* compressed_certs_cache, 39 QuicCompressedCertsCache* compressed_certs_cache,
40 QuicTestServer::StreamFactory* factory, 40 QuicTestServer::StreamFactory* factory,
41 QuicTestServer::CryptoStreamFactory* crypto_stream_factory) 41 QuicTestServer::CryptoStreamFactory* crypto_stream_factory)
42 : QuicSimpleServerSession(config, 42 : QuicSimpleServerSession(config,
43 connection, 43 connection,
44 visitor, 44 visitor,
45 helper, 45 helper,
46 crypto_config, 46 crypto_config,
47 compressed_certs_cache), 47 compressed_certs_cache),
(...skipping 27 matching lines...) Expand all
75 QuicTestServer::CryptoStreamFactory* crypto_stream_factory_; // Not owned. 75 QuicTestServer::CryptoStreamFactory* crypto_stream_factory_; // Not owned.
76 }; 76 };
77 77
78 class QuicTestDispatcher : public QuicSimpleDispatcher { 78 class QuicTestDispatcher : public QuicSimpleDispatcher {
79 public: 79 public:
80 QuicTestDispatcher( 80 QuicTestDispatcher(
81 const QuicConfig& config, 81 const QuicConfig& config,
82 const QuicCryptoServerConfig* crypto_config, 82 const QuicCryptoServerConfig* crypto_config,
83 QuicVersionManager* version_manager, 83 QuicVersionManager* version_manager,
84 std::unique_ptr<QuicConnectionHelperInterface> helper, 84 std::unique_ptr<QuicConnectionHelperInterface> helper,
85 std::unique_ptr<QuicServerSessionBase::Helper> session_helper, 85 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
86 std::unique_ptr<QuicAlarmFactory> alarm_factory) 86 std::unique_ptr<QuicAlarmFactory> alarm_factory)
87 : QuicSimpleDispatcher(config, 87 : QuicSimpleDispatcher(config,
88 crypto_config, 88 crypto_config,
89 version_manager, 89 version_manager,
90 std::move(helper), 90 std::move(helper),
91 std::move(session_helper), 91 std::move(session_helper),
92 std::move(alarm_factory)), 92 std::move(alarm_factory)),
93 session_factory_(nullptr), 93 session_factory_(nullptr),
94 stream_factory_(nullptr), 94 stream_factory_(nullptr),
95 crypto_stream_factory_(nullptr) {} 95 crypto_stream_factory_(nullptr) {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 : QuicServer(std::move(proof_source), 158 : QuicServer(std::move(proof_source),
159 config, 159 config,
160 QuicCryptoServerConfig::ConfigOptions(), 160 QuicCryptoServerConfig::ConfigOptions(),
161 supported_versions) {} 161 supported_versions) {}
162 162
163 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { 163 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() {
164 return new QuicTestDispatcher( 164 return new QuicTestDispatcher(
165 config(), &crypto_config(), version_manager(), 165 config(), &crypto_config(), version_manager(),
166 std::unique_ptr<QuicEpollConnectionHelper>(new QuicEpollConnectionHelper( 166 std::unique_ptr<QuicEpollConnectionHelper>(new QuicEpollConnectionHelper(
167 epoll_server(), QuicAllocator::BUFFER_POOL)), 167 epoll_server(), QuicAllocator::BUFFER_POOL)),
168 std::unique_ptr<QuicServerSessionBase::Helper>( 168 std::unique_ptr<QuicCryptoServerStream::Helper>(
169 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), 169 new QuicSimpleCryptoServerStreamHelper(QuicRandom::GetInstance())),
170 std::unique_ptr<QuicEpollAlarmFactory>( 170 std::unique_ptr<QuicEpollAlarmFactory>(
171 new QuicEpollAlarmFactory(epoll_server()))); 171 new QuicEpollAlarmFactory(epoll_server())));
172 } 172 }
173 173
174 void QuicTestServer::SetSessionFactory(SessionFactory* factory) { 174 void QuicTestServer::SetSessionFactory(SessionFactory* factory) {
175 DCHECK(dispatcher()); 175 DCHECK(dispatcher());
176 static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory); 176 static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory);
177 } 177 }
178 178
179 void QuicTestServer::SetSpdyStreamFactory(StreamFactory* factory) { 179 void QuicTestServer::SetSpdyStreamFactory(StreamFactory* factory) {
180 static_cast<QuicTestDispatcher*>(dispatcher())->SetStreamFactory(factory); 180 static_cast<QuicTestDispatcher*>(dispatcher())->SetStreamFactory(factory);
181 } 181 }
182 182
183 void QuicTestServer::SetCryptoStreamFactory(CryptoStreamFactory* factory) { 183 void QuicTestServer::SetCryptoStreamFactory(CryptoStreamFactory* factory) {
184 static_cast<QuicTestDispatcher*>(dispatcher()) 184 static_cast<QuicTestDispatcher*>(dispatcher())
185 ->SetCryptoStreamFactory(factory); 185 ->SetCryptoStreamFactory(factory);
186 } 186 }
187 187
188 /////////////////////////// TEST SESSIONS /////////////////////////////// 188 /////////////////////////// TEST SESSIONS ///////////////////////////////
189 189
190 ImmediateGoAwaySession::ImmediateGoAwaySession( 190 ImmediateGoAwaySession::ImmediateGoAwaySession(
191 const QuicConfig& config, 191 const QuicConfig& config,
192 QuicConnection* connection, 192 QuicConnection* connection,
193 QuicServerSessionBase::Visitor* visitor, 193 QuicServerSessionBase::Visitor* visitor,
194 QuicServerSessionBase::Helper* helper, 194 QuicCryptoServerStream::Helper* helper,
195 const QuicCryptoServerConfig* crypto_config, 195 const QuicCryptoServerConfig* crypto_config,
196 QuicCompressedCertsCache* compressed_certs_cache) 196 QuicCompressedCertsCache* compressed_certs_cache)
197 : QuicSimpleServerSession(config, 197 : QuicSimpleServerSession(config,
198 connection, 198 connection,
199 visitor, 199 visitor,
200 helper, 200 helper,
201 crypto_config, 201 crypto_config,
202 compressed_certs_cache) {} 202 compressed_certs_cache) {}
203 203
204 void ImmediateGoAwaySession::OnStreamFrame(const QuicStreamFrame& frame) { 204 void ImmediateGoAwaySession::OnStreamFrame(const QuicStreamFrame& frame) {
205 SendGoAway(QUIC_PEER_GOING_AWAY, ""); 205 SendGoAway(QUIC_PEER_GOING_AWAY, "");
206 QuicSimpleServerSession::OnStreamFrame(frame); 206 QuicSimpleServerSession::OnStreamFrame(frame);
207 } 207 }
208 208
209 } // namespace test 209 } // namespace test
210 } // namespace net 210 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698