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

Unified Diff: net/quic/quic_p2p_session_factory.cc

Issue 474383003: Initial P2P implementation for WebRTC on QUIC prototype Base URL: https://chromium.googlesource.com/chromium/src.git@tests-squashed
Patch Set: Created 6 years, 4 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
« no previous file with comments | « net/quic/quic_p2p_session_factory.h ('k') | third_party/libjingle/libjingle.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_p2p_session_factory.cc
diff --git a/net/quic/quic_p2p_session_factory.cc b/net/quic/quic_p2p_session_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aa12bb0fd7f76042e93d7c59549c3dad9c920ec9
--- /dev/null
+++ b/net/quic/quic_p2p_session_factory.cc
@@ -0,0 +1,85 @@
+// Copyright 2014 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/quic_p2p_session_factory.h"
+
+#include "net/cert/x509_certificate.h"
+#include "net/quic/crypto/quic_random.h"
+#include "net/quic/quic_connection.h"
+#include "net/quic/quic_p2p_client_session.h"
+#include "net/quic/quic_p2p_server_session.h"
+
+namespace net {
+
+namespace {
+string MakeSecret(QuicRandom* random) {
+ uint8 buf[16];
+ random->RandBytes(buf, sizeof(buf));
+ return string(reinterpret_cast<char*>(buf), sizeof(buf));
+}
+} // namespace
+
+QuicP2PSessionFactory::QuicP2PSessionFactory(
+ QuicConnectionHelperInterface* helper)
+ : helper_(helper),
+ server_config_(MakeSecret(helper->GetRandomGenerator()),
+ helper->GetRandomGenerator()) {
+ client_config_.SetDefaults();
+ client_config_.set_user_agent_id("P2P");
+ // TODO(dmz) more on server_config_
+ server_config_.AddDefaultConfig(helper->GetRandomGenerator(),
+ helper->GetClock(),
+ QuicCryptoServerConfig::ConfigOptions());
+}
+
+QuicP2PSession* QuicP2PSessionFactory::Create(
+ bool is_server_role,
+ X509Certificate* local_identity,
+ base::StringPiece private_key,
+ HashValue remote_fingerprint,
+ QuicPacketWriter* writer,
+ QuicP2PSession::Delegate* delegate,
+ QuicMessageStream::ReadDelegate* read_delegate) {
+ QuicConnection* connection = new QuicConnection(
+ 0xa5adface, // TODO(dmz)
+ IPEndPoint(),
+ helper_,
+ is_server_role,
+ QuicSupportedVersions());
+ connection->set_writer(writer, /* owned= */ false);
+ QuicConfig config;
+ config.SetDefaults();
+ // Let P2PTransportChannel handle the timeouts
+ config.set_idle_connection_state_lifetime(
+ QuicTime::Delta::FromSeconds(1000),
+ QuicTime::Delta::FromSeconds(1000));
+ // TODO(dmz) This should probably use the same options as the normal QUIC
+ // running in the I/O thread. We need to get at
+ // IOThread::globals_->quic_connection_options somehow.
+ QuicTagVector connection_options;
+ connection_options.push_back(net::kPACE);
+ connection_options.push_back(net::kTIME);
+ config.SetConnectionOptionsToSend(connection_options);
+ QuicP2PSession* session;
+ if (is_server_role) {
+ session = new QuicP2PServerSession(config,
+ &server_config_,
+ connection,
+ delegate,
+ read_delegate);
+ } else {
+ // TODO(dmz) more on client_config_
+ // TODO(dmz) QuicServerId has to match
+ session = new QuicP2PClientSession(config,
+ QuicServerId(),
+ &client_config_,
+ connection,
+ delegate,
+ read_delegate);
+ }
+ session->InitializeSession();
+ return session;
+}
+
+} // namespace net
« no previous file with comments | « net/quic/quic_p2p_session_factory.h ('k') | third_party/libjingle/libjingle.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698