Index: webrtc/p2p/base/faketransportcontroller.h |
diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h |
index b8c67ecd17aacaab29e459ed264ed6afb3508b54..3f191e54857481008eff87e9628cb48deedb418a 100644 |
--- a/webrtc/p2p/base/faketransportcontroller.h |
+++ b/webrtc/p2p/base/faketransportcontroller.h |
@@ -65,6 +65,7 @@ class FakeTransportChannel : public TransportChannelImpl, |
// If async, will send packets by "Post"-ing to message queue instead of |
// synchronously "Send"-ing. |
void SetAsync(bool async) { async_ = async; } |
+ void SetAsyncDelay(int delay_ms) { async_delay_ms_ = delay_ms; } |
TransportChannelState GetState() const override { |
if (connection_count_ == 0) { |
@@ -198,7 +199,12 @@ class FakeTransportChannel : public TransportChannelImpl, |
PacketMessageData* packet = new PacketMessageData(data, len); |
if (async_) { |
- rtc::Thread::Current()->Post(RTC_FROM_HERE, this, 0, packet); |
+ if (async_delay_ms_) { |
+ rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, async_delay_ms_, |
+ this, 0, packet); |
+ } else { |
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, 0, packet); |
+ } |
} else { |
rtc::Thread::Current()->Send(RTC_FROM_HERE, this, 0, packet); |
} |
@@ -309,6 +315,7 @@ class FakeTransportChannel : public TransportChannelImpl, |
FakeTransportChannel* dest_ = nullptr; |
State state_ = STATE_INIT; |
bool async_ = false; |
+ int async_delay_ms_ = 0; |
Candidates remote_candidates_; |
rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; |
rtc::FakeSSLCertificate* remote_cert_ = nullptr; |
@@ -352,6 +359,7 @@ class FakeTransport : public Transport { |
// If async, will send packets by "Post"-ing to message queue instead of |
// synchronously "Send"-ing. |
void SetAsync(bool async) { async_ = async; } |
+ void SetAsyncDelay(int delay_ms) { async_delay_ms_ = delay_ms; } |
// If |asymmetric| is true, only set the destination for this transport, and |
// not |dest|. |
@@ -413,6 +421,7 @@ class FakeTransport : public Transport { |
FakeTransportChannel* channel = new FakeTransportChannel(name(), component); |
channel->set_ssl_max_protocol_version(ssl_max_version_); |
channel->SetAsync(async_); |
+ channel->SetAsyncDelay(async_delay_ms_); |
SetChannelDestination(component, channel, false); |
channels_[component] = channel; |
return channel; |
@@ -449,6 +458,7 @@ class FakeTransport : public Transport { |
ChannelMap channels_; |
FakeTransport* dest_ = nullptr; |
bool async_ = false; |
+ int async_delay_ms_ = 0; |
rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
}; |