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

Side by Side Diff: webrtc/p2p/quic/quicsession.cc

Issue 1648763002: Create QuicSession (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modify QuicSession unit test string comparison asserts Created 4 years, 10 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <string>
12 #include <utility>
13
14 #include "webrtc/base/messagehandler.h"
15 #include "webrtc/base/messagequeue.h"
16 #include "webrtc/p2p/quic/quicsession.h"
17 #include "webrtc/base/logging.h"
Taylor Brandstetter 2016/02/06 00:22:44 nit: Sort includes
mikescarlett 2016/02/06 02:14:08 Done.
18
19 namespace cricket {
20
21 QuicSession::QuicSession(scoped_ptr<net::QuicConnection> connection,
22 const net::QuicConfig& config)
23 : net::QuicSession(connection.release(), config) {}
24
25 QuicSession::~QuicSession() {}
26
27 void QuicSession::StartClientHandshake(
28 net::QuicCryptoClientStream* crypto_stream) {
29 SetCryptoStream(crypto_stream);
30 net::QuicSession::Initialize();
31 crypto_stream->CryptoConnect();
32 }
33
34 void QuicSession::StartServerHandshake(
35 net::QuicCryptoServerStream* crypto_stream) {
36 SetCryptoStream(crypto_stream);
37 net::QuicSession::Initialize();
38 }
39
40 void QuicSession::SetCryptoStream(net::QuicCryptoStream* crypto_stream) {
41 crypto_stream_.reset(crypto_stream);
42 }
43
44 bool QuicSession::ExportKeyingMaterial(base::StringPiece label,
45 base::StringPiece context,
46 size_t result_len,
47 string* result) {
48 return GetCryptoStream()->ExportKeyingMaterial(label, context, result_len,
Taylor Brandstetter 2016/02/06 00:22:44 I would just use crypto_stream_ instead of GetCryp
mikescarlett 2016/02/06 02:14:08 I replaced this.
49 result);
50 }
51
52 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
53 net::QuicSession::OnCryptoHandshakeEvent(event);
54 if (event == HANDSHAKE_CONFIRMED) {
55 LOG(INFO) << "QuicSession handshake complete";
Taylor Brandstetter 2016/02/06 00:22:44 I'm used to seeing LS_INFO; I think that's what we
pthatcher1 2016/02/06 00:40:29 They are exactly the same: https://code.google.co
mikescarlett 2016/02/06 02:14:09 I'll keep LOG(INFO) since it appears both are used
56 DCHECK(IsEncryptionEstablished());
Taylor Brandstetter 2016/02/06 00:22:44 RTC_DCHECK
mikescarlett 2016/02/06 02:14:08 Done.
57 DCHECK(IsCryptoHandshakeConfirmed());
58
59 SignalHandshakeComplete();
60 }
61 }
62
63 ReliableQuicStream* QuicSession::CreateIncomingDynamicStream(
64 net::QuicStreamId id) {
65 ReliableQuicStream* stream = CreateDataStream(id);
66 if (stream) {
67 SignalIncomingStream(stream);
68 }
69 return stream;
70 }
71
72 ReliableQuicStream* QuicSession::CreateOutgoingDynamicStream(
73 net::SpdyPriority priority) {
74 ReliableQuicStream* stream = CreateDataStream(GetNextOutgoingStreamId());
75 if (stream) {
76 ActivateStream(stream);
77 }
78 return stream;
79 }
80
81 ReliableQuicStream* QuicSession::CreateDataStream(net::QuicStreamId id) {
82 net::QuicCryptoStream* crypto_stream = GetCryptoStream();
Taylor Brandstetter 2016/02/06 00:22:44 Same as above, I'd suggest just using crypto_strea
mikescarlett 2016/02/06 02:14:09 This is also replaced.
83 if (crypto_stream == nullptr || !crypto_stream->encryption_established()) {
84 // Encryption not active so no stream created
85 return nullptr;
86 }
87 return new ReliableQuicStream(id, this);
88 }
89
90 void QuicSession::OnConnectionClosed(net::QuicErrorCode error, bool from_peer) {
91 net::QuicSession::OnConnectionClosed(error, from_peer);
92
Taylor Brandstetter 2016/02/06 00:22:44 nit: Whitespace seems unnecessary
mikescarlett 2016/02/06 02:14:09 I removed it.
93 SignalConnectionClosed(error, from_peer);
94 }
95
96 bool QuicSession::OnReadPacket(const char* data, size_t data_len) {
97 net::QuicEncryptedPacket packet(data, data_len);
98 connection()->ProcessUdpPacket(connection()->self_address(),
99 connection()->peer_address(), packet);
100 return true;
101 }
102
103 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698