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

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

Issue 1856943002: Allow TransportController to create a QuicTransportChannel (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Sync to upstream Created 4 years, 7 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 | « webrtc/p2p/quic/quictransport.h ('k') | webrtc/p2p/quic/quictransport_unittest.cc » ('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 /*
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 "webrtc/p2p/quic/quictransport.h"
12
13 #include "webrtc/p2p/base/p2ptransportchannel.h"
14
15 namespace cricket {
16
17 QuicTransport::QuicTransport(
18 const std::string& name,
19 PortAllocator* allocator,
20 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
21 : Transport(name, allocator), local_certificate_(certificate) {}
22
23 QuicTransport::~QuicTransport() {
24 DestroyAllChannels();
25 }
26
27 void QuicTransport::SetLocalCertificate(
28 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
29 local_certificate_ = certificate;
30 }
31 bool QuicTransport::GetLocalCertificate(
32 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
33 if (!local_certificate_) {
34 return false;
35 }
36 *certificate = local_certificate_;
37 return true;
38 }
39
40 bool QuicTransport::ApplyLocalTransportDescription(
41 TransportChannelImpl* channel,
42 std::string* error_desc) {
43 rtc::SSLFingerprint* local_fp =
44 local_description()->identity_fingerprint.get();
45 if (!VerifyCertificateFingerprint(local_certificate_.get(), local_fp,
46 error_desc)) {
47 return false;
48 }
49 if (!channel->SetLocalCertificate(local_certificate_)) {
50 return BadTransportDescription("Failed to set local identity.", error_desc);
51 }
52 return Transport::ApplyLocalTransportDescription(channel, error_desc);
53 }
54
55 bool QuicTransport::NegotiateTransportDescription(ContentAction action,
56 std::string* error_desc) {
57 if (!local_description() || !remote_description()) {
58 const std::string msg =
59 "Local and Remote description must be set before "
60 "transport descriptions are negotiated";
61 return BadTransportDescription(msg, error_desc);
62 }
63 rtc::SSLFingerprint* local_fp =
64 local_description()->identity_fingerprint.get();
65 rtc::SSLFingerprint* remote_fp =
66 remote_description()->identity_fingerprint.get();
67 if (!local_fp || !remote_fp) {
68 return BadTransportDescription("Fingerprints must be supplied for QUIC.",
69 error_desc);
70 }
71 remote_fingerprint_.reset(new rtc::SSLFingerprint(*remote_fp));
72 if (!NegotiateRole(action, &local_role_, error_desc)) {
73 return false;
74 }
75 // Now run the negotiation for the Transport class.
76 return Transport::NegotiateTransportDescription(action, error_desc);
77 }
78
79 QuicTransportChannel* QuicTransport::CreateTransportChannel(int component) {
80 P2PTransportChannel* ice_channel =
81 new P2PTransportChannel(name(), component, port_allocator());
82 return new QuicTransportChannel(ice_channel);
83 }
84
85 void QuicTransport::DestroyTransportChannel(TransportChannelImpl* channel) {
86 delete channel;
87 }
88
89 bool QuicTransport::GetSslRole(rtc::SSLRole* ssl_role) const {
90 ASSERT(ssl_role != NULL);
91 *ssl_role = local_role_;
92 return true;
93 }
94
95 bool QuicTransport::ApplyNegotiatedTransportDescription(
96 TransportChannelImpl* channel,
97 std::string* error_desc) {
98 // Set ssl role and remote fingerprint. These are required for QUIC setup.
99 if (!channel->SetSslRole(local_role_)) {
100 return BadTransportDescription("Failed to set ssl role for the channel.",
101 error_desc);
102 }
103 // Apply remote fingerprint.
104 if (!channel->SetRemoteFingerprint(
105 remote_fingerprint_->algorithm,
106 reinterpret_cast<const uint8_t*>(remote_fingerprint_->digest.data()),
107 remote_fingerprint_->digest.size())) {
108 return BadTransportDescription("Failed to apply remote fingerprint.",
109 error_desc);
110 }
111 return Transport::ApplyNegotiatedTransportDescription(channel, error_desc);
112 }
113
114 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/quic/quictransport.h ('k') | webrtc/p2p/quic/quictransport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698