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..3bc87ca4db9986534fcbfa5951a8c9c778096ef6 |
| --- /dev/null |
| +++ b/net/quic/quartc/quartc_factory.cc |
| @@ -0,0 +1,50 @@ |
| +// 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); |
|
pthatcher2
2016/10/05 22:12:05
Why do we bother storing this as a member variable
Ryan Hamilton
2016/10/10 19:48:30
Agreed. This seems confusing because it means that
zhihuang1
2016/10/13 06:22:39
I'll remove these member variables.
|
| + return std::unique_ptr<QuartcSessionInterface>( |
| + new QuartcSession(std::move(quic_connection), *(config_.get()), |
| + quartc_config.remote_fingerprint_value, perspective, |
| + quartc_config.transport)); |
| +} |
| + |
| +std::unique_ptr<QuicConnection> QuartcFactory::CreateQuicConnection( |
| + const QuartcConfig& quartc_config, |
| + Perspective perspective) { |
| + // The QuicConnection will take ownership. |
|
pthatcher2
2016/10/05 22:12:05
That might be more clear if you used std::unique_p
zhihuang1
2016/10/13 06:22:39
Done.
|
| + QuartcPacketWriter* writer = new QuartcPacketWriter(quartc_config.transport); |
| + helper_.reset(new QuartcConnectionHelper); |
|
pthatcher2
2016/10/05 22:12:05
Why do we bother storing it in a member variable?
|
| + alarm_factory_.reset(new QuartcAlarmFactory( |
| + base::ThreadTaskRunnerHandle::Get().get(), helper_->GetClock())); |
| + IPAddress ip(0, 0, 0, 0); |
|
pthatcher2
2016/10/05 22:12:05
This could use a comment with some explanation.
zhihuang1
2016/10/13 06:22:39
Done.
|
| + return std::unique_ptr<QuicConnection>(new QuicConnection( |
| + 0, IPEndPoint(ip, 0), helper_.get(), alarm_factory_.get(), writer, |
|
pthatcher2
2016/10/05 22:12:05
A local variable the 0 here a name would help read
zhihuang1
2016/10/13 06:22:39
Done.
|
| + true /*own the writer*/, perspective, AllSupportedVersions())); |
| +} |
| + |
| +std::unique_ptr<QuartcFactoryInterface> CreateQuartcFactory() { |
| + return std::unique_ptr<QuartcFactoryInterface>(new QuartcFactory); |
| +} |
| + |
| +} // namespace net |