Chromium Code Reviews| Index: net/quic/quartc/quartc_factory.cc |
| diff --git a/net/quic/quartc/quartc_factory.cc b/net/quic/quartc/quartc_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..495f12e39770c095ff7936e47d4eca7ce3e71034 |
| --- /dev/null |
| +++ b/net/quic/quartc/quartc_factory.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "net/quic/quartc/quartc_factory.h" |
| + |
| +#include "base/threading/thread_task_runner_handle.h" |
| +#include "net/quic/quartc/quartc_alarm_factory.h" |
| +#include "net/quic/quartc/quartc_connection_helper.h" |
| +#include "net/quic/quartc/quartc_session.h" |
| + |
| +namespace net { |
| + |
| +QuartcFactory::QuartcFactory() {} |
| +QuartcFactory::~QuartcFactory() {} |
| + |
| +std::unique_ptr<QuartcSessionInterface> QuartcFactory::CreateQuartcSession( |
| + const QuartcConfig& quartc_config) { |
| + DCHECK(quartc_config.transport); |
| + |
| + Perspective perspective = |
| + quartc_config.is_server ? Perspective::IS_SERVER : Perspective::IS_CLIENT; |
| + std::unique_ptr<QuicConnection> quic_connection = |
| + CreateQuicConnection(quartc_config, perspective); |
| + config_.reset(new QuicConfig); |
|
skvlad-chromium
2016/09/23 19:09:42
Do you actually need to keep the config around? It
|
| + std::unique_ptr<QuartcSessionInterface> quartc_session( |
| + new QuartcSession(std::move(quic_connection), *(config_.get()), |
| + quartc_config.remote_fingerprint_value, perspective, |
| + quartc_config.transport)); |
| + return quartc_session; |
| +} |
| + |
| +std::unique_ptr<QuicConnection> QuartcFactory::CreateQuicConnection( |
| + const QuartcConfig& quartc_config, |
| + Perspective perspective) { |
| + // The QuicConnection will take ownership. |
| + QuartcPacketWriter* writer = new QuartcPacketWriter(quartc_config.transport); |
| + helper_.reset(new QuartcConnectionHelper); |
| + alarm_factory_.reset(new QuartcAlarmFactory( |
| + base::ThreadTaskRunnerHandle::Get().get(), helper_->GetClock())); |
| + IPAddress ip(0, 0, 0, 0); |
| + return std::unique_ptr<QuicConnection>(new QuicConnection( |
| + 0, IPEndPoint(ip, 0), helper_.get(), alarm_factory_.get(), writer, |
| + true /*own the writer*/, perspective, AllSupportedVersions())); |
| +} |
| + |
| +std::unique_ptr<QuartcFactoryInterface> CreateQuartcFactory() { |
| + return std::unique_ptr<QuartcFactoryInterface>(new QuartcFactory); |
| +} |
| + |
| +} // namespace net |