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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/quic_p2p_session.h"
6
7 #include "net/quic/quic_connection.h"
8
9 namespace net {
10
11 QuicP2PSession::QuicP2PSession(
12 const QuicConfig& config,
13 QuicConnection* connection,
14 QuicP2PSession::Delegate* delegate,
15 QuicMessageStream::ReadDelegate* read_delegate)
16 : QuicClientSessionBase(connection, config),
17 delegate_(delegate),
18 read_delegate_(read_delegate) {
19 }
20 QuicP2PSession::~QuicP2PSession() {}
21
22 // TODO(dmz): QuicServerSession::OnConnectionClose calls
23 // crypto_stream_->CancelOutstandingCallbacks(), but I think that should be
24 // necessary since ~QuicCryptoServerStream also does.
25
26 bool QuicP2PSession::GetPeerCertificate(X509Certificate** cert) {
27 return false; // TODO(dmz)
28 }
29
30 bool QuicP2PSession::OnPacketRead(const char* data, size_t data_len) {
31 DVLOG(1) << "QuicP2PSession got packet: " << data_len << " bytes";
32 QuicEncryptedPacket packet(data, data_len);
33 // TODO(dmz)
34 connection()->ProcessUdpPacket(IPEndPoint({127,0,0,1}, 5000),
35 IPEndPoint({127,0,0,1}, 5000), packet);
36 return true;
37 }
38
39 int QuicP2PSession::WriteMessage(QuicStreamId stream_id,
40 const char* data,
41 size_t data_len) {
42 QuicMessageStream* stream = static_cast<QuicMessageStream*>(
43 (*streams())[stream_id]);
44 return stream->WriteStreamData(base::StringPiece(data, data_len), false);
45 }
46
47 bool QuicP2PSession::ExportKeyingMaterial(base::StringPiece label,
48 base::StringPiece context,
49 size_t result_len,
50 string* result) {
51 return GetCryptoStream()->ExportKeyingMaterial(label,
52 context,
53 result_len,
54 result);
55 }
56
57 void QuicP2PSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
58 QuicClientSessionBase::OnCryptoHandshakeEvent(event);
59 if (event == HANDSHAKE_CONFIRMED) {
60 DVLOG(1) << "QuicP2PSession handshake complete";
61 delegate_->OnHandshakeComplete();
62 }
63 }
64
65 QuicDataStream* QuicP2PSession::CreateIncomingDataStream(QuicStreamId id) {
66 QuicDataStream* stream = CreateDataStream(id);
67 ActivateStream(stream); // TODO(dmz) necessary?
68 return stream;
69 }
70
71 QuicDataStream* QuicP2PSession::CreateOutgoingDataStream() {
72 return CreateDataStream(GetNextStreamId());
73 }
74
75 QuicDataStream* QuicP2PSession::CreateDataStream(QuicStreamId id) {
76 if (!GetCryptoStream()->encryption_established()) {
77 DVLOG(1) << "Encryption not active so no stream created.";
78 return NULL;
79 }
80 if (GetNumOpenStreams() >= get_max_open_streams()) {
81 DVLOG(1) << "Failed to create a new outgoing stream. "
82 << "Already " << GetNumOpenStreams() << " open.";
83 return NULL;
84 }
85 return new QuicMessageStream(id, this, read_delegate_);
86 }
87
88 } // namespace net
OLDNEW
« 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