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

Unified Diff: net/quic/quic_p2p_session.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.h ('k') | net/quic/quic_p2p_session_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_p2p_session.cc
diff --git a/net/quic/quic_p2p_session.cc b/net/quic/quic_p2p_session.cc
new file mode 100644
index 0000000000000000000000000000000000000000..907c549684775fe01d617e2cc4c3372086cce550
--- /dev/null
+++ b/net/quic/quic_p2p_session.cc
@@ -0,0 +1,88 @@
+// 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.h"
+
+#include "net/quic/quic_connection.h"
+
+namespace net {
+
+QuicP2PSession::QuicP2PSession(
+ const QuicConfig& config,
+ QuicConnection* connection,
+ QuicP2PSession::Delegate* delegate,
+ QuicMessageStream::ReadDelegate* read_delegate)
+ : QuicClientSessionBase(connection, config),
+ delegate_(delegate),
+ read_delegate_(read_delegate) {
+}
+QuicP2PSession::~QuicP2PSession() {}
+
+// TODO(dmz): QuicServerSession::OnConnectionClose calls
+// crypto_stream_->CancelOutstandingCallbacks(), but I think that should be
+// necessary since ~QuicCryptoServerStream also does.
+
+bool QuicP2PSession::GetPeerCertificate(X509Certificate** cert) {
+ return false; // TODO(dmz)
+}
+
+bool QuicP2PSession::OnPacketRead(const char* data, size_t data_len) {
+ DVLOG(1) << "QuicP2PSession got packet: " << data_len << " bytes";
+ QuicEncryptedPacket packet(data, data_len);
+ // TODO(dmz)
+ connection()->ProcessUdpPacket(IPEndPoint({127,0,0,1}, 5000),
+ IPEndPoint({127,0,0,1}, 5000), packet);
+ return true;
+}
+
+int QuicP2PSession::WriteMessage(QuicStreamId stream_id,
+ const char* data,
+ size_t data_len) {
+ QuicMessageStream* stream = static_cast<QuicMessageStream*>(
+ (*streams())[stream_id]);
+ return stream->WriteStreamData(base::StringPiece(data, data_len), false);
+}
+
+bool QuicP2PSession::ExportKeyingMaterial(base::StringPiece label,
+ base::StringPiece context,
+ size_t result_len,
+ string* result) {
+ return GetCryptoStream()->ExportKeyingMaterial(label,
+ context,
+ result_len,
+ result);
+}
+
+void QuicP2PSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
+ QuicClientSessionBase::OnCryptoHandshakeEvent(event);
+ if (event == HANDSHAKE_CONFIRMED) {
+ DVLOG(1) << "QuicP2PSession handshake complete";
+ delegate_->OnHandshakeComplete();
+ }
+}
+
+QuicDataStream* QuicP2PSession::CreateIncomingDataStream(QuicStreamId id) {
+ QuicDataStream* stream = CreateDataStream(id);
+ ActivateStream(stream); // TODO(dmz) necessary?
+ return stream;
+}
+
+QuicDataStream* QuicP2PSession::CreateOutgoingDataStream() {
+ return CreateDataStream(GetNextStreamId());
+}
+
+QuicDataStream* QuicP2PSession::CreateDataStream(QuicStreamId id) {
+ if (!GetCryptoStream()->encryption_established()) {
+ DVLOG(1) << "Encryption not active so no stream created.";
+ return NULL;
+ }
+ if (GetNumOpenStreams() >= get_max_open_streams()) {
+ DVLOG(1) << "Failed to create a new outgoing stream. "
+ << "Already " << GetNumOpenStreams() << " open.";
+ return NULL;
+ }
+ return new QuicMessageStream(id, this, read_delegate_);
+}
+
+} // namespace net
« no previous file with comments | « net/quic/quic_p2p_session.h ('k') | net/quic/quic_p2p_session_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698