Index: webrtc/p2p/base/faketransportcontroller.h |
diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h |
index 153aa56790a9e443dacda6a317e93c5a62b9bc92..5d0ceb434d8ce3b5f254409ef71be23d2d11ad04 100644 |
--- a/webrtc/p2p/base/faketransportcontroller.h |
+++ b/webrtc/p2p/base/faketransportcontroller.h |
@@ -69,6 +69,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) { |
@@ -200,7 +201,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); |
} |
@@ -311,6 +317,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; |
@@ -354,6 +361,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|. |
@@ -415,6 +423,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; |
@@ -451,6 +460,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; |
}; |