Ignore empty data in DataChannel::Send to match FF's behavior.
BUG=crbug/395205 R=pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/16949004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6742 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
99f6308a2d
commit
3edbaaf337
@ -195,6 +195,14 @@ bool DataChannel::Send(const DataBuffer& buffer) {
|
|||||||
if (state_ != kOpen) {
|
if (state_ != kOpen) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(jiayl): the spec is unclear about if the remote side should get the
|
||||||
|
// onmessage event. We need to figure out the expected behavior and change the
|
||||||
|
// code accordingly.
|
||||||
|
if (buffer.size() == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// If the queue is non-empty, we're waiting for SignalReadyToSend,
|
// If the queue is non-empty, we're waiting for SignalReadyToSend,
|
||||||
// so just add to the end of the queue and keep waiting.
|
// so just add to the end of the queue and keep waiting.
|
||||||
if (!queued_send_data_.Empty()) {
|
if (!queued_send_data_.Empty()) {
|
||||||
|
@ -410,3 +410,16 @@ TEST_F(SctpDataChannelTest, ClosedWhenReceivedBufferFull) {
|
|||||||
EXPECT_EQ(webrtc::DataChannelInterface::kClosed,
|
EXPECT_EQ(webrtc::DataChannelInterface::kClosed,
|
||||||
webrtc_data_channel_->state());
|
webrtc_data_channel_->state());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that sending empty data returns no error and keeps the channel open.
|
||||||
|
TEST_F(SctpDataChannelTest, SendEmptyData) {
|
||||||
|
webrtc_data_channel_->SetSctpSid(1);
|
||||||
|
SetChannelReady();
|
||||||
|
EXPECT_EQ(webrtc::DataChannelInterface::kOpen,
|
||||||
|
webrtc_data_channel_->state());
|
||||||
|
|
||||||
|
webrtc::DataBuffer buffer("");
|
||||||
|
EXPECT_TRUE(webrtc_data_channel_->Send(buffer));
|
||||||
|
EXPECT_EQ(webrtc::DataChannelInterface::kOpen,
|
||||||
|
webrtc_data_channel_->state());
|
||||||
|
}
|
||||||
|
@ -45,7 +45,7 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transport_error_) {
|
if (transport_error_ || payload.length() == 0) {
|
||||||
*result = cricket::SDR_ERROR;
|
*result = cricket::SDR_ERROR;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user