Chromium Code Reviews| Index: webrtc/api/quicdatatransport.cc |
| diff --git a/webrtc/api/quicdatatransport.cc b/webrtc/api/quicdatatransport.cc |
| index c1caf54067ebbfeb6e084b23e69ca679aa5a7cba..8a54a6cd66a5f041188d1b3a3347becbbccc3cba 100644 |
| --- a/webrtc/api/quicdatatransport.cc |
| +++ b/webrtc/api/quicdatatransport.cc |
| @@ -10,24 +10,47 @@ |
| #include "webrtc/api/quicdatatransport.h" |
| +#include "webrtc/base/bind.h" |
| #include "webrtc/base/logging.h" |
| #include "webrtc/p2p/quic/quictransportchannel.h" |
| #include "webrtc/p2p/quic/reliablequicstream.h" |
| namespace webrtc { |
| -QuicDataTransport::QuicDataTransport(rtc::Thread* signaling_thread, |
| - rtc::Thread* worker_thread, |
| - rtc::Thread* network_thread) |
| +QuicDataTransport::QuicDataTransport( |
| + rtc::Thread* signaling_thread, |
| + rtc::Thread* worker_thread, |
| + rtc::Thread* network_thread, |
| + cricket::TransportController* transport_controller) |
| : signaling_thread_(signaling_thread), |
| worker_thread_(worker_thread), |
| - network_thread_(network_thread) { |
| + network_thread_(network_thread), |
| + transport_controller_(transport_controller) { |
| RTC_DCHECK(signaling_thread_); |
| RTC_DCHECK(worker_thread_); |
| RTC_DCHECK(network_thread_); |
| } |
| -QuicDataTransport::~QuicDataTransport() {} |
| +QuicDataTransport::~QuicDataTransport() { |
| + DestroyTransportChannels(); |
|
pthatcher1
2016/07/27 23:21:49
DestroyTransportChannel(quic_transport_channel_);
Zhi Huang
2016/08/01 05:12:28
Done.
|
| + LOG(LS_INFO) << "Destroyed the QUIC data transport."; |
| +} |
| + |
| +bool QuicDataTransport::SetTransport(const std::string& transport_name) { |
| + if (transport_name_ == transport_name) { |
| + // Nothing to do if transport name isn't changing |
| + return true; |
| + } |
| + |
|
pthatcher1
2016/07/27 23:21:49
tc = CreateTransportChannel(transport_name);
if (!
|
| + SetTransportChannel(CreateTransportChannel(transport_name)); |
| + |
| + if (!quic_transport_channel_) { |
| + return false; |
| + } |
|
pthatcher1
2016/07/27 23:21:49
You don't need this if you have the "return false"
Zhi Huang
2016/08/01 05:12:28
Done.
|
| + |
| + transport_name_ = transport_name; |
| + return true; |
| +} |
| bool QuicDataTransport::SetTransportChannel( |
| cricket::QuicTransportChannel* channel) { |
| @@ -147,4 +170,28 @@ void QuicDataTransport::OnDataReceived(net::QuicStreamId id, |
| data_channel->OnIncomingMessage(std::move(message)); |
| } |
| +cricket::QuicTransportChannel* QuicDataTransport::CreateTransportChannel( |
| + const std::string& transport_name) { |
| + cricket::TransportChannel* transport_channel = |
| + network_thread_->Invoke<cricket::TransportChannel*>( |
| + RTC_FROM_HERE, |
| + rtc::Bind(&cricket::TransportController::CreateTransportChannel_n, |
| + transport_controller_, transport_name, |
| + cricket::ICE_CANDIDATE_COMPONENT_DEFAULT)); |
| + if (!transport_channel) { |
| + return nullptr; |
| + } |
|
pthatcher1
2016/07/27 23:21:49
You don't need this
Zhi Huang
2016/08/01 05:12:28
Done.
|
| + return static_cast<cricket::QuicTransportChannel*>(transport_channel); |
| +} |
| + |
| +void QuicDataTransport::DestroyTransportChannels() { |
|
pthatcher1
2016/07/27 23:21:49
DestroyTransportChannel(TransportChannel* tc)
|
| + if (quic_transport_channel_) { |
|
pthatcher1
2016/07/27 23:21:49
if (!tc) {
return;
}
network_thread_->Invoke<voi
|
| + network_thread_->Invoke<void>( |
| + RTC_FROM_HERE, |
| + rtc::Bind(&cricket::TransportController::DestroyTransportChannel_n, |
| + transport_controller_, transport_name_, |
| + cricket::ICE_CANDIDATE_COMPONENT_DEFAULT)); |
| + } |
| +} |
| + |
| } // namespace webrtc |