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

Unified Diff: net/quic/quartc/quartc_factory.cc

Issue 2324833004: Define Stable API for WebRTC/Quartc (Closed)
Patch Set: Patch Set 4 : Create QuartcFactory. Made modification on the API. Change the constructor of QuartcS… Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698