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

Side by Side Diff: webrtc/api/quicdatatransport.cc

Issue 2206793007: Revert of Modified PeerConnection and WebRtcSession for end-to-end QuicDataChannel usage. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 | « webrtc/api/quicdatatransport.h ('k') | webrtc/api/quicdatatransport_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
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/quicdatatransport.h" 11 #include "webrtc/api/quicdatatransport.h"
12 12
13 #include "webrtc/base/bind.h"
14 #include "webrtc/base/logging.h" 13 #include "webrtc/base/logging.h"
15 #include "webrtc/p2p/quic/quictransportchannel.h" 14 #include "webrtc/p2p/quic/quictransportchannel.h"
16 #include "webrtc/p2p/quic/reliablequicstream.h" 15 #include "webrtc/p2p/quic/reliablequicstream.h"
17 16
18 namespace webrtc { 17 namespace webrtc {
19 18
20 QuicDataTransport::QuicDataTransport( 19 QuicDataTransport::QuicDataTransport(rtc::Thread* signaling_thread,
21 rtc::Thread* signaling_thread, 20 rtc::Thread* worker_thread,
22 rtc::Thread* worker_thread, 21 rtc::Thread* network_thread)
23 rtc::Thread* network_thread,
24 cricket::TransportController* transport_controller)
25 : signaling_thread_(signaling_thread), 22 : signaling_thread_(signaling_thread),
26 worker_thread_(worker_thread), 23 worker_thread_(worker_thread),
27 network_thread_(network_thread), 24 network_thread_(network_thread) {
28 transport_controller_(transport_controller) {
29 RTC_DCHECK(signaling_thread_); 25 RTC_DCHECK(signaling_thread_);
30 RTC_DCHECK(worker_thread_); 26 RTC_DCHECK(worker_thread_);
31 RTC_DCHECK(network_thread_); 27 RTC_DCHECK(network_thread_);
32 } 28 }
33 29
34 QuicDataTransport::~QuicDataTransport() { 30 QuicDataTransport::~QuicDataTransport() {}
35 DestroyTransportChannel(quic_transport_channel_);
36 LOG(LS_INFO) << "Destroyed the QUIC data transport.";
37 }
38
39 bool QuicDataTransport::SetTransport(const std::string& transport_name) {
40 if (transport_name_ == transport_name) {
41 // Nothing to do if transport name isn't changing
42 return true;
43 }
44
45 cricket::QuicTransportChannel* transport_channel =
46 CreateTransportChannel(transport_name);
47 if (!SetTransportChannel(transport_channel)) {
48 DestroyTransportChannel(transport_channel);
49 return false;
50 }
51
52 transport_name_ = transport_name;
53 return true;
54 }
55 31
56 bool QuicDataTransport::SetTransportChannel( 32 bool QuicDataTransport::SetTransportChannel(
57 cricket::QuicTransportChannel* channel) { 33 cricket::QuicTransportChannel* channel) {
58 if (!channel) { 34 if (!channel) {
59 LOG(LS_ERROR) << "|channel| is NULL. Cannot set transport channel."; 35 LOG(LS_ERROR) << "|channel| is NULL. Cannot set transport channel.";
60 return false; 36 return false;
61 } 37 }
62 if (quic_transport_channel_) { 38 if (quic_transport_channel_) {
63 if (channel == quic_transport_channel_) { 39 if (channel == quic_transport_channel_) {
64 LOG(LS_WARNING) << "Ignoring duplicate transport channel."; 40 LOG(LS_WARNING) << "Ignoring duplicate transport channel.";
65 return true; 41 return true;
66 } 42 }
67 LOG(LS_ERROR) << "|channel| does not match existing transport channel."; 43 LOG(LS_ERROR) << "|channel| does not match existing transport channel.";
68 return false; 44 return false;
69 } 45 }
70 46
71 LOG(LS_INFO) << "Setting QuicTransportChannel for QuicDataTransport"; 47 LOG(LS_INFO) << "Setting QuicTransportChannel for QuicDataTransport";
72 quic_transport_channel_ = channel; 48 quic_transport_channel_ = channel;
73 quic_transport_channel_->SignalIncomingStream.connect( 49 quic_transport_channel_->SignalIncomingStream.connect(
74 this, &QuicDataTransport::OnIncomingStream); 50 this, &QuicDataTransport::OnIncomingStream);
51
75 bool success = true; 52 bool success = true;
76 for (const auto& kv : data_channel_by_id_) { 53 for (const auto& kv : data_channel_by_id_) {
77 rtc::scoped_refptr<QuicDataChannel> data_channel = kv.second; 54 rtc::scoped_refptr<QuicDataChannel> data_channel = kv.second;
78 if (!data_channel->SetTransportChannel(quic_transport_channel_)) { 55 if (!data_channel->SetTransportChannel(quic_transport_channel_)) {
79 LOG(LS_ERROR) 56 LOG(LS_ERROR)
80 << "Cannot set QUIC transport channel for QUIC data channel " 57 << "Cannot set QUIC transport channel for QUIC data channel "
81 << kv.first; 58 << kv.first;
82 success = false; 59 success = false;
83 } 60 }
84 } 61 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return; 140 return;
164 } 141 }
165 QuicDataChannel* data_channel = data_channel_kv->second; 142 QuicDataChannel* data_channel = data_channel_kv->second;
166 QuicDataChannel::Message message; 143 QuicDataChannel::Message message;
167 message.id = message_id; 144 message.id = message_id;
168 message.buffer = rtc::CopyOnWriteBuffer(data, len); 145 message.buffer = rtc::CopyOnWriteBuffer(data, len);
169 message.stream = stream; 146 message.stream = stream;
170 data_channel->OnIncomingMessage(std::move(message)); 147 data_channel->OnIncomingMessage(std::move(message));
171 } 148 }
172 149
173 cricket::QuicTransportChannel* QuicDataTransport::CreateTransportChannel(
174 const std::string& transport_name) {
175 DCHECK(transport_controller_->quic());
176
177 cricket::TransportChannel* transport_channel =
178 network_thread_->Invoke<cricket::TransportChannel*>(
179 RTC_FROM_HERE,
180 rtc::Bind(&cricket::TransportController::CreateTransportChannel_n,
181 transport_controller_, transport_name,
182 cricket::ICE_CANDIDATE_COMPONENT_DEFAULT));
183 return static_cast<cricket::QuicTransportChannel*>(transport_channel);
184 }
185
186 void QuicDataTransport::DestroyTransportChannel(
187 cricket::TransportChannel* transport_channel) {
188 if (transport_channel) {
189 network_thread_->Invoke<void>(
190 RTC_FROM_HERE,
191 rtc::Bind(&cricket::TransportController::DestroyTransportChannel_n,
192 transport_controller_, transport_channel->transport_name(),
193 cricket::ICE_CANDIDATE_COMPONENT_DEFAULT));
194 }
195 }
196
197 } // namespace webrtc 150 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/quicdatatransport.h ('k') | webrtc/api/quicdatatransport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698