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:
jiayl@webrtc.org 2014-07-18 23:57:50 +00:00
parent 99f6308a2d
commit 3edbaaf337
3 changed files with 22 additions and 1 deletions

View File

@ -195,6 +195,14 @@ bool DataChannel::Send(const DataBuffer& buffer) {
if (state_ != kOpen) {
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,
// so just add to the end of the queue and keep waiting.
if (!queued_send_data_.Empty()) {

View File

@ -410,3 +410,16 @@ TEST_F(SctpDataChannelTest, ClosedWhenReceivedBufferFull) {
EXPECT_EQ(webrtc::DataChannelInterface::kClosed,
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());
}

View File

@ -45,7 +45,7 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
return false;
}
if (transport_error_) {
if (transport_error_ || payload.length() == 0) {
*result = cricket::SDR_ERROR;
return false;
}