OLD | NEW |
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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 private: | 69 private: |
70 QuicTestServer::StreamFactory* stream_factory_; // Not owned. | 70 QuicTestServer::StreamFactory* stream_factory_; // Not owned. |
71 QuicTestServer::CryptoStreamFactory* crypto_stream_factory_; // Not owned. | 71 QuicTestServer::CryptoStreamFactory* crypto_stream_factory_; // Not owned. |
72 }; | 72 }; |
73 | 73 |
74 class QuicTestDispatcher : public QuicDispatcher { | 74 class QuicTestDispatcher : public QuicDispatcher { |
75 public: | 75 public: |
76 QuicTestDispatcher(const QuicConfig& config, | 76 QuicTestDispatcher(const QuicConfig& config, |
77 const QuicCryptoServerConfig* crypto_config, | 77 const QuicCryptoServerConfig* crypto_config, |
78 const QuicVersionVector& versions, | 78 const QuicVersionVector& versions, |
79 QuicConnectionHelperInterface* helper) | 79 std::unique_ptr<QuicConnectionHelperInterface> helper) |
80 : QuicDispatcher(config, crypto_config, versions, helper), | 80 : QuicDispatcher(config, crypto_config, versions, std::move(helper)), |
81 session_factory_(nullptr), | 81 session_factory_(nullptr), |
82 stream_factory_(nullptr), | 82 stream_factory_(nullptr), |
83 crypto_stream_factory_(nullptr) {} | 83 crypto_stream_factory_(nullptr) {} |
84 | 84 |
85 QuicServerSessionBase* CreateQuicSession(QuicConnectionId id, | 85 QuicServerSessionBase* CreateQuicSession(QuicConnectionId id, |
86 const IPEndPoint& client) override { | 86 const IPEndPoint& client) override { |
87 base::AutoLock lock(factory_lock_); | 87 base::AutoLock lock(factory_lock_); |
88 if (session_factory_ == nullptr && stream_factory_ == nullptr && | 88 if (session_factory_ == nullptr && stream_factory_ == nullptr && |
89 crypto_stream_factory_ == nullptr) { | 89 crypto_stream_factory_ == nullptr) { |
90 return QuicDispatcher::CreateQuicSession(id, client); | 90 return QuicDispatcher::CreateQuicSession(id, client); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 const QuicConfig& config, | 143 const QuicConfig& config, |
144 const QuicVersionVector& supported_versions) | 144 const QuicVersionVector& supported_versions) |
145 : QuicServer(proof_source, | 145 : QuicServer(proof_source, |
146 config, | 146 config, |
147 QuicCryptoServerConfig::ConfigOptions(), | 147 QuicCryptoServerConfig::ConfigOptions(), |
148 supported_versions) {} | 148 supported_versions) {} |
149 | 149 |
150 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { | 150 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { |
151 return new QuicTestDispatcher( | 151 return new QuicTestDispatcher( |
152 config(), &crypto_config(), supported_versions(), | 152 config(), &crypto_config(), supported_versions(), |
153 new QuicEpollConnectionHelper(epoll_server(), | 153 std::unique_ptr<QuicEpollConnectionHelper>(new QuicEpollConnectionHelper( |
154 QuicAllocator::BUFFER_POOL)); | 154 epoll_server(), QuicAllocator::BUFFER_POOL))); |
155 } | 155 } |
156 | 156 |
157 void QuicTestServer::SetSessionFactory(SessionFactory* factory) { | 157 void QuicTestServer::SetSessionFactory(SessionFactory* factory) { |
158 DCHECK(dispatcher()); | 158 DCHECK(dispatcher()); |
159 static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory); | 159 static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory); |
160 } | 160 } |
161 | 161 |
162 void QuicTestServer::SetSpdyStreamFactory(StreamFactory* factory) { | 162 void QuicTestServer::SetSpdyStreamFactory(StreamFactory* factory) { |
163 static_cast<QuicTestDispatcher*>(dispatcher())->SetStreamFactory(factory); | 163 static_cast<QuicTestDispatcher*>(dispatcher())->SetStreamFactory(factory); |
164 } | 164 } |
(...skipping 14 matching lines...) Expand all Loading... |
179 : QuicSimpleServerSession(config, | 179 : QuicSimpleServerSession(config, |
180 connection, | 180 connection, |
181 visitor, | 181 visitor, |
182 crypto_config, | 182 crypto_config, |
183 compressed_certs_cache) { | 183 compressed_certs_cache) { |
184 SendGoAway(QUIC_PEER_GOING_AWAY, ""); | 184 SendGoAway(QUIC_PEER_GOING_AWAY, ""); |
185 } | 185 } |
186 | 186 |
187 } // namespace test | 187 } // namespace test |
188 } // namespace net | 188 } // namespace net |
OLD | NEW |