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

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

Issue 1908103002: Landing Recent QUIC changes until 4/15/2016 17:20 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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) 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/thread_task_runner_handle.h" 10 #include "base/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/crypto/crypto_handshake.h" 13 #include "net/quic/crypto/crypto_handshake.h"
14 #include "net/quic/crypto/quic_crypto_server_config.h" 14 #include "net/quic/crypto/quic_crypto_server_config.h"
15 #include "net/quic/crypto/quic_random.h" 15 #include "net/quic/crypto/quic_random.h"
16 #include "net/quic/quic_chromium_connection_helper.h" 16 #include "net/quic/quic_chromium_connection_helper.h"
17 #include "net/quic/quic_config.h" 17 #include "net/quic/quic_config.h"
18 #include "net/quic/quic_connection.h" 18 #include "net/quic/quic_connection.h"
19 #include "net/quic/quic_packet_writer.h" 19 #include "net/quic/quic_packet_writer.h"
20 #include "net/quic/quic_protocol.h" 20 #include "net/quic/quic_protocol.h"
21 #include "net/tools/quic/quic_dispatcher.h" 21 #include "net/tools/quic/quic_dispatcher.h"
22 #include "net/tools/quic/quic_epoll_alarm_factory.h"
22 #include "net/tools/quic/quic_epoll_connection_helper.h" 23 #include "net/tools/quic/quic_epoll_connection_helper.h"
23 #include "net/tools/quic/quic_simple_server_session.h" 24 #include "net/tools/quic/quic_simple_server_session.h"
24 #include "net/tools/quic/quic_simple_server_stream.h" 25 #include "net/tools/quic/quic_simple_server_stream.h"
25 26
26 namespace net { 27 namespace net {
27 namespace test { 28 namespace test {
28 29
29 class CustomStreamSession : public QuicSimpleServerSession { 30 class CustomStreamSession : public QuicSimpleServerSession {
30 public: 31 public:
31 CustomStreamSession( 32 CustomStreamSession(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 private: 70 private:
70 QuicTestServer::StreamFactory* stream_factory_; // Not owned. 71 QuicTestServer::StreamFactory* stream_factory_; // Not owned.
71 QuicTestServer::CryptoStreamFactory* crypto_stream_factory_; // Not owned. 72 QuicTestServer::CryptoStreamFactory* crypto_stream_factory_; // Not owned.
72 }; 73 };
73 74
74 class QuicTestDispatcher : public QuicDispatcher { 75 class QuicTestDispatcher : public QuicDispatcher {
75 public: 76 public:
76 QuicTestDispatcher(const QuicConfig& config, 77 QuicTestDispatcher(const QuicConfig& config,
77 const QuicCryptoServerConfig* crypto_config, 78 const QuicCryptoServerConfig* crypto_config,
78 const QuicVersionVector& versions, 79 const QuicVersionVector& versions,
79 QuicConnectionHelperInterface* helper) 80 std::unique_ptr<QuicConnectionHelperInterface> helper,
80 : QuicDispatcher(config, crypto_config, versions, helper), 81 std::unique_ptr<QuicAlarmFactory> alarm_factory)
82 : QuicDispatcher(config,
83 crypto_config,
84 versions,
85 std::move(helper),
86 std::move(alarm_factory)),
81 session_factory_(nullptr), 87 session_factory_(nullptr),
82 stream_factory_(nullptr), 88 stream_factory_(nullptr),
83 crypto_stream_factory_(nullptr) {} 89 crypto_stream_factory_(nullptr) {}
84 90
85 QuicServerSessionBase* CreateQuicSession(QuicConnectionId id, 91 QuicServerSessionBase* CreateQuicSession(QuicConnectionId id,
86 const IPEndPoint& client) override { 92 const IPEndPoint& client) override {
87 base::AutoLock lock(factory_lock_); 93 base::AutoLock lock(factory_lock_);
88 if (session_factory_ == nullptr && stream_factory_ == nullptr && 94 if (session_factory_ == nullptr && stream_factory_ == nullptr &&
89 crypto_stream_factory_ == nullptr) { 95 crypto_stream_factory_ == nullptr) {
90 return QuicDispatcher::CreateQuicSession(id, client); 96 return QuicDispatcher::CreateQuicSession(id, client);
91 } 97 }
92 QuicConnection* connection = new QuicConnection( 98 QuicConnection* connection = new QuicConnection(
93 id, client, helper(), CreatePerConnectionWriter(), 99 id, client, helper(), alarm_factory(), CreatePerConnectionWriter(),
94 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions()); 100 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions());
95 101
96 QuicServerSessionBase* session = nullptr; 102 QuicServerSessionBase* session = nullptr;
97 if (stream_factory_ != nullptr || crypto_stream_factory_ != nullptr) { 103 if (stream_factory_ != nullptr || crypto_stream_factory_ != nullptr) {
98 session = new CustomStreamSession( 104 session = new CustomStreamSession(
99 config(), connection, this, crypto_config(), compressed_certs_cache(), 105 config(), connection, this, crypto_config(), compressed_certs_cache(),
100 stream_factory_, crypto_stream_factory_); 106 stream_factory_, crypto_stream_factory_);
101 } else { 107 } else {
102 session = session_factory_->CreateSession(config(), connection, this, 108 session = session_factory_->CreateSession(config(), connection, this,
103 crypto_config(), 109 crypto_config(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const QuicConfig& config, 149 const QuicConfig& config,
144 const QuicVersionVector& supported_versions) 150 const QuicVersionVector& supported_versions)
145 : QuicServer(proof_source, 151 : QuicServer(proof_source,
146 config, 152 config,
147 QuicCryptoServerConfig::ConfigOptions(), 153 QuicCryptoServerConfig::ConfigOptions(),
148 supported_versions) {} 154 supported_versions) {}
149 155
150 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { 156 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() {
151 return new QuicTestDispatcher( 157 return new QuicTestDispatcher(
152 config(), &crypto_config(), supported_versions(), 158 config(), &crypto_config(), supported_versions(),
153 new QuicEpollConnectionHelper(epoll_server(), 159 std::unique_ptr<QuicEpollConnectionHelper>(new QuicEpollConnectionHelper(
154 QuicAllocator::BUFFER_POOL)); 160 epoll_server(), QuicAllocator::BUFFER_POOL)),
161 std::unique_ptr<QuicEpollAlarmFactory>(
162 new QuicEpollAlarmFactory(epoll_server())));
155 } 163 }
156 164
157 void QuicTestServer::SetSessionFactory(SessionFactory* factory) { 165 void QuicTestServer::SetSessionFactory(SessionFactory* factory) {
158 DCHECK(dispatcher()); 166 DCHECK(dispatcher());
159 static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory); 167 static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory);
160 } 168 }
161 169
162 void QuicTestServer::SetSpdyStreamFactory(StreamFactory* factory) { 170 void QuicTestServer::SetSpdyStreamFactory(StreamFactory* factory) {
163 static_cast<QuicTestDispatcher*>(dispatcher())->SetStreamFactory(factory); 171 static_cast<QuicTestDispatcher*>(dispatcher())->SetStreamFactory(factory);
164 } 172 }
(...skipping 14 matching lines...) Expand all
179 : QuicSimpleServerSession(config, 187 : QuicSimpleServerSession(config,
180 connection, 188 connection,
181 visitor, 189 visitor,
182 crypto_config, 190 crypto_config,
183 compressed_certs_cache) { 191 compressed_certs_cache) {
184 SendGoAway(QUIC_PEER_GOING_AWAY, ""); 192 SendGoAway(QUIC_PEER_GOING_AWAY, "");
185 } 193 }
186 194
187 } // namespace test 195 } // namespace test
188 } // namespace net 196 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.cc ('k') | net/tools/quic/test_tools/server_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698