Revert of Modify PeerConnection for end-to-end QuicDataChannel usage (patchset #4 id:60001 of https://codereview.webrtc.org/2089553002/ )
Reason for revert:
Reverting because description was inaccurate. Will reland after updating description.
Original issue's description:
> Modify PeerConnection for end-to-end QuicDataChannel usage
>
> To allow end-to-end QuicDataChannel usage with a
> PeerConnection, RTCConfiguration has been modified to
> include a boolean for whether to do QUIC, since negotiation of
> QUIC is not implemented. If one peer does QUIC, then it will be
> assumed that the other peer must do QUIC or the connection
> will fail.
>
> PeerConnection has been modified to create data channels of type
> QuicDataChannel when the peer wants to do QUIC.
>
> WebRtcSession has been modified to use a QuicTransportChannel
> instead of a DtlsTransportChannelWrapper/DataChannel
> when QUIC should be used.
>
> Modification of previous in-flight CL: https://codereview.chromium.org/1844803002/
>
> Committed: https://crrev.com/36c8d69ce188102ae6fd48c371cf1518f08698fb
> Cr-Commit-Position: refs/heads/master@{#13470}
TBR=pthatcher@webrtc.org,zhihuang@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review-Url: https://codereview.webrtc.org/2146133002
Cr-Commit-Position: refs/heads/master@{#13471}
diff --git a/webrtc/api/quicdatachannel.cc b/webrtc/api/quicdatachannel.cc
index 5493382..f4f5732 100644
--- a/webrtc/api/quicdatachannel.cc
+++ b/webrtc/api/quicdatachannel.cc
@@ -61,12 +61,10 @@
QuicDataChannel::QuicDataChannel(rtc::Thread* signaling_thread,
rtc::Thread* worker_thread,
- rtc::Thread* network_thread,
const std::string& label,
const DataChannelInit& config)
: signaling_thread_(signaling_thread),
worker_thread_(worker_thread),
- network_thread_(network_thread),
id_(config.id),
state_(kConnecting),
buffered_amount_(0),
@@ -93,12 +91,12 @@
<< " is not open so cannot send.";
return false;
}
- return network_thread_->Invoke<bool>(
- RTC_FROM_HERE, rtc::Bind(&QuicDataChannel::Send_n, this, buffer));
+ return worker_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&QuicDataChannel::Send_w, this, buffer));
}
-bool QuicDataChannel::Send_n(const DataBuffer& buffer) {
- RTC_DCHECK(network_thread_->IsCurrent());
+bool QuicDataChannel::Send_w(const DataBuffer& buffer) {
+ RTC_DCHECK(worker_thread_->IsCurrent());
// Encode and send the header containing the data channel ID and message ID.
rtc::CopyOnWriteBuffer header;
@@ -258,7 +256,7 @@
}
void QuicDataChannel::OnIncomingMessage(Message&& message) {
- RTC_DCHECK(network_thread_->IsCurrent());
+ RTC_DCHECK(worker_thread_->IsCurrent());
RTC_DCHECK(message.stream);
if (!observer_) {
LOG(LS_WARNING) << "QUIC data channel " << id_
@@ -297,7 +295,7 @@
void QuicDataChannel::OnDataReceived(net::QuicStreamId stream_id,
const char* data,
size_t len) {
- RTC_DCHECK(network_thread_->IsCurrent());
+ RTC_DCHECK(worker_thread_->IsCurrent());
RTC_DCHECK(data);
const auto& kv = incoming_quic_messages_.find(stream_id);
if (kv == incoming_quic_messages_.end()) {
@@ -327,7 +325,7 @@
}
void QuicDataChannel::OnReadyToSend(cricket::TransportChannel* channel) {
- RTC_DCHECK(network_thread_->IsCurrent());
+ RTC_DCHECK(worker_thread_->IsCurrent());
RTC_DCHECK(channel == quic_transport_channel_);
LOG(LS_INFO) << "QuicTransportChannel is ready to send";
invoker_.AsyncInvoke<void>(
@@ -344,7 +342,7 @@
void QuicDataChannel::OnIncomingQueuedStreamClosed(net::QuicStreamId stream_id,
int error) {
- RTC_DCHECK(network_thread_->IsCurrent());
+ RTC_DCHECK(worker_thread_->IsCurrent());
LOG(LS_VERBOSE) << "Incoming queued stream " << stream_id << " is closed.";
incoming_quic_messages_.erase(stream_id);
}
diff --git a/webrtc/api/quicdatachannel.h b/webrtc/api/quicdatachannel.h
index 18a10ac..a6b987b 100644
--- a/webrtc/api/quicdatachannel.h
+++ b/webrtc/api/quicdatachannel.h
@@ -88,7 +88,6 @@
QuicDataChannel(rtc::Thread* signaling_thread,
rtc::Thread* worker_thread,
- rtc::Thread* network_thread,
const std::string& label,
const DataChannelInit& config);
~QuicDataChannel() override;
@@ -156,13 +155,11 @@
void OnReadyToSend(cricket::TransportChannel* channel);
void OnConnectionClosed();
- // Network thread methods.
+ // Worker thread methods.
// Sends the data buffer to the remote peer using an outgoing QUIC stream.
// Returns true if the data buffer can be successfully sent, or if it is
// queued to be sent later.
- bool Send_n(const DataBuffer& buffer);
-
- // Worker thread methods.
+ bool Send_w(const DataBuffer& buffer);
// Connects the |quic_transport_channel_| signals to this QuicDataChannel,
// then returns the new QuicDataChannel state.
DataState SetTransportChannel_w();
@@ -188,10 +185,8 @@
cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
// Signaling thread for DataChannelInterface methods.
rtc::Thread* const signaling_thread_;
- // Worker thread for |quic_transport_channel_| callbacks.
+ // Worker thread for sending data and |quic_transport_channel_| callbacks.
rtc::Thread* const worker_thread_;
- // Network thread for sending data and |quic_transport_channel_| callbacks.
- rtc::Thread* const network_thread_;
rtc::AsyncInvoker invoker_;
// Map of QUIC stream ID => ReliableQuicStream* for write blocked QUIC
// streams.
diff --git a/webrtc/api/quicdatachannel_unittest.cc b/webrtc/api/quicdatachannel_unittest.cc
index 7245ccf..e701c29 100644
--- a/webrtc/api/quicdatachannel_unittest.cc
+++ b/webrtc/api/quicdatachannel_unittest.cc
@@ -120,9 +120,8 @@
DataChannelInit config;
config.id = id;
config.protocol = protocol;
- rtc::scoped_refptr<QuicDataChannel> data_channel(
- new QuicDataChannel(rtc::Thread::Current(), rtc::Thread::Current(),
- rtc::Thread::Current(), label, config));
+ rtc::scoped_refptr<QuicDataChannel> data_channel(new QuicDataChannel(
+ rtc::Thread::Current(), rtc::Thread::Current(), label, config));
data_channel_by_id_[id] = data_channel;
return data_channel;
}
@@ -202,6 +201,8 @@
// Connects |ice_transport_channel_| to that of the other peer.
void Connect(QuicDataChannelPeer* other_peer) {
+ ice_transport_channel_->Connect();
+ other_peer->ice_transport_channel_->Connect();
ice_transport_channel_->SetDestination(other_peer->ice_transport_channel_);
}
diff --git a/webrtc/api/quicdatatransport.cc b/webrtc/api/quicdatatransport.cc
index c1caf54..70ad03d 100644
--- a/webrtc/api/quicdatatransport.cc
+++ b/webrtc/api/quicdatatransport.cc
@@ -17,14 +17,10 @@
namespace webrtc {
QuicDataTransport::QuicDataTransport(rtc::Thread* signaling_thread,
- rtc::Thread* worker_thread,
- rtc::Thread* network_thread)
- : signaling_thread_(signaling_thread),
- worker_thread_(worker_thread),
- network_thread_(network_thread) {
+ rtc::Thread* worker_thread)
+ : signaling_thread_(signaling_thread), worker_thread_(worker_thread) {
RTC_DCHECK(signaling_thread_);
RTC_DCHECK(worker_thread_);
- RTC_DCHECK(network_thread_);
}
QuicDataTransport::~QuicDataTransport() {}
@@ -72,8 +68,8 @@
LOG(LS_ERROR) << "QUIC data channel already exists with id " << config->id;
return nullptr;
}
- rtc::scoped_refptr<QuicDataChannel> data_channel(new QuicDataChannel(
- signaling_thread_, worker_thread_, network_thread_, label, *config));
+ rtc::scoped_refptr<QuicDataChannel> data_channel(
+ new QuicDataChannel(signaling_thread_, worker_thread_, label, *config));
if (quic_transport_channel_) {
if (!data_channel->SetTransportChannel(quic_transport_channel_)) {
LOG(LS_ERROR)
diff --git a/webrtc/api/quicdatatransport.h b/webrtc/api/quicdatatransport.h
index 96fe2a0..f0c427d 100644
--- a/webrtc/api/quicdatatransport.h
+++ b/webrtc/api/quicdatatransport.h
@@ -36,9 +36,7 @@
// exists, it sends the QUIC stream to the QuicDataChannel.
class QuicDataTransport : public sigslot::has_slots<> {
public:
- QuicDataTransport(rtc::Thread* signaling_thread,
- rtc::Thread* worker_thread,
- rtc::Thread* network_thread);
+ QuicDataTransport(rtc::Thread* signaling_thread, rtc::Thread* worker_thread);
~QuicDataTransport() override;
// Sets the QUIC transport channel for the QuicDataChannels and the
@@ -82,10 +80,9 @@
quic_stream_by_id_;
// QuicTransportChannel for sending/receiving data.
cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
- // Threads for the QUIC data channel.
+ // Signaling and worker threads for the QUIC data channel.
rtc::Thread* const signaling_thread_;
rtc::Thread* const worker_thread_;
- rtc::Thread* const network_thread_;
};
} // namespace webrtc
diff --git a/webrtc/api/quicdatatransport_unittest.cc b/webrtc/api/quicdatatransport_unittest.cc
index 975898e..d668c55 100644
--- a/webrtc/api/quicdatatransport_unittest.cc
+++ b/webrtc/api/quicdatatransport_unittest.cc
@@ -64,9 +64,7 @@
class QuicDataTransportPeer {
public:
QuicDataTransportPeer()
- : quic_data_transport_(rtc::Thread::Current(),
- rtc::Thread::Current(),
- rtc::Thread::Current()),
+ : quic_data_transport_(rtc::Thread::Current(), rtc::Thread::Current()),
ice_transport_channel_(new FakeTransportChannel("data", 0)),
quic_transport_channel_(ice_transport_channel_) {
ice_transport_channel_->SetAsync(true);
@@ -82,6 +80,8 @@
// Connects |ice_transport_channel_| to that of the other peer.
void Connect(QuicDataTransportPeer* other_peer) {
+ ice_transport_channel_->Connect();
+ other_peer->ice_transport_channel_->Connect();
ice_transport_channel_->SetDestination(other_peer->ice_transport_channel_);
}