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

Unified Diff: webrtc/p2p/base/quicsession.cc

Issue 1648763002: Create QuicSession (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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: webrtc/p2p/base/quicsession.cc
diff --git a/webrtc/p2p/base/quicsession.cc b/webrtc/p2p/base/quicsession.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e75b3407631ee85aa513cf788384978099da2f08
--- /dev/null
+++ b/webrtc/p2p/base/quicsession.cc
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2011 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <string>
+#include <utility>
+
+#include "webrtc/base/messagehandler.h"
+#include "webrtc/base/messagequeue.h"
+#include "webrtc/p2p/base/quicsession.h"
+#include "webrtc/base/logging.h"
+
+namespace cricket {
+
+QuicSession::QuicSession(const net::QuicConfig& config,
+ scoped_ptr<net::QuicConnection> connection)
+ : net::QuicSession(connection.release(), config) {}
+
+QuicSession::~QuicSession() {}
+
+void QuicSession::StartClientHandshake(
+ net::QuicCryptoClientStream* crypto_stream) {
+ SetCryptoStream(crypto_stream);
+ net::QuicSession::Initialize();
+ crypto_stream->CryptoConnect();
+}
+
+void QuicSession::StartServerHandshake(
+ net::QuicCryptoServerStream* crypto_stream) {
+ SetCryptoStream(crypto_stream);
+ net::QuicSession::Initialize();
+}
+
+void QuicSession::SetCryptoStream(net::QuicCryptoStream* crypto_stream) {
+ crypto_stream_.reset(crypto_stream);
+}
+
+bool QuicSession::ExportKeyingMaterial(base::StringPiece label,
+ base::StringPiece context,
+ size_t result_len,
+ string* result) {
+ return GetCryptoStream()->ExportKeyingMaterial(label, context, result_len,
+ result);
+}
+
+void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
+ net::QuicSession::OnCryptoHandshakeEvent(event);
+ if (event == HANDSHAKE_CONFIRMED) {
+ VLOG(1) << "QuicSession handshake complete";
pthatcher1 2016/01/30 03:01:52 VLOG(1)? We usually use something like LOG(INFO).
mikescarlett 2016/02/03 17:41:01 Fixed.
+ DCHECK(IsEncryptionEstablished());
+ DCHECK(IsCryptoHandshakeConfirmed());
+
+ SignalHandshakeComplete();
+ }
+}
+
+ReliableQuicStream* QuicSession::CreateIncomingDynamicStream(
+ net::QuicStreamId id) {
+ ReliableQuicStream* stream = CreateDataStream(id);
+ SignalIncomingStream(stream);
pthatcher1 2016/01/30 03:01:52 Should this also be in an "if (stream)"?
mikescarlett 2016/02/03 17:41:01 Yes it should.
+ return stream;
+}
+
+ReliableQuicStream* QuicSession::CreateOutgoingDynamicStream(
+ net::SpdyPriority priority) {
+ ReliableQuicStream* stream = CreateDataStream(GetNextOutgoingStreamId());
+ if (stream) {
+ ActivateStream(stream);
+ }
+ return stream;
+}
+
+ReliableQuicStream* QuicSession::CreateDataStream(net::QuicStreamId id) {
+ if (!GetCryptoStream()->encryption_established()) {
+ // Encryption not active so no stream created
+ return nullptr;
+ }
+ return new ReliableQuicStream(id, this);
+}
+
+void QuicSession::OnConnectionClosed(net::QuicErrorCode error, bool from_peer) {
+ net::QuicSession::OnConnectionClosed(error, from_peer);
+
+ SignalConnectionClosed(error, from_peer);
+}
+
+bool QuicSession::OnReadPacket(const char* data, size_t data_len) {
+ net::QuicEncryptedPacket packet(data, data_len);
+ connection()->ProcessUdpPacket(connection()->self_address(),
+ connection()->peer_address(), packet);
+ return true;
+}
+
+} // namespace cricket

Powered by Google App Engine
This is Rietveld 408576698