Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/quic/quartc/quartc_factory.h" | |
| 6 | |
| 7 #include "base/threading/thread_task_runner_handle.h" | |
| 8 #include "net/quic/quartc/quartc_alarm_factory.h" | |
| 9 #include "net/quic/quartc/quartc_connection_helper.h" | |
| 10 #include "net/quic/quartc/quartc_session.h" | |
| 11 | |
| 12 namespace net { | |
| 13 | |
| 14 QuartcFactory::QuartcFactory() {} | |
| 15 QuartcFactory::~QuartcFactory() {} | |
| 16 | |
| 17 std::unique_ptr<QuartcSessionInterface> QuartcFactory::CreateQuartcSession( | |
| 18 const QuartcConfig& quartc_config) { | |
| 19 DCHECK(quartc_config.transport); | |
| 20 | |
| 21 Perspective perspective = | |
| 22 quartc_config.is_server ? Perspective::IS_SERVER : Perspective::IS_CLIENT; | |
| 23 std::unique_ptr<QuicConnection> quic_connection = | |
| 24 CreateQuicConnection(quartc_config, perspective); | |
| 25 config_.reset(new QuicConfig); | |
|
skvlad-chromium
2016/09/23 19:09:42
Do you actually need to keep the config around? It
| |
| 26 std::unique_ptr<QuartcSessionInterface> quartc_session( | |
| 27 new QuartcSession(std::move(quic_connection), *(config_.get()), | |
| 28 quartc_config.remote_fingerprint_value, perspective, | |
| 29 quartc_config.transport)); | |
| 30 return quartc_session; | |
| 31 } | |
| 32 | |
| 33 std::unique_ptr<QuicConnection> QuartcFactory::CreateQuicConnection( | |
| 34 const QuartcConfig& quartc_config, | |
| 35 Perspective perspective) { | |
| 36 // The QuicConnection will take ownership. | |
| 37 QuartcPacketWriter* writer = new QuartcPacketWriter(quartc_config.transport); | |
| 38 helper_.reset(new QuartcConnectionHelper); | |
| 39 alarm_factory_.reset(new QuartcAlarmFactory( | |
| 40 base::ThreadTaskRunnerHandle::Get().get(), helper_->GetClock())); | |
| 41 IPAddress ip(0, 0, 0, 0); | |
| 42 return std::unique_ptr<QuicConnection>(new QuicConnection( | |
| 43 0, IPEndPoint(ip, 0), helper_.get(), alarm_factory_.get(), writer, | |
| 44 true /*own the writer*/, perspective, AllSupportedVersions())); | |
| 45 } | |
| 46 | |
| 47 std::unique_ptr<QuartcFactoryInterface> CreateQuartcFactory() { | |
| 48 return std::unique_ptr<QuartcFactoryInterface>(new QuartcFactory); | |
| 49 } | |
| 50 | |
| 51 } // namespace net | |
| OLD | NEW |