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

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

Issue 1907773002: Make QuicDispatcher's helper argument be a unique_ptr to make ownership (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119678304
Patch Set: Rebase 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
« no previous file with comments | « net/tools/quic/quic_simple_server_test.cc ('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/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
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
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
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
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698