Index: media/cast/transport/transport/udp_transport.cc |
diff --git a/media/cast/transport/transport/udp_transport.cc b/media/cast/transport/transport/udp_transport.cc |
index bcce4f72f3172d1764e5d588cb880ae093908827..578b9593e9a6bd8333bb78ad42b3a590acd0edee 100644 |
--- a/media/cast/transport/transport/udp_transport.cc |
+++ b/media/cast/transport/transport/udp_transport.cc |
@@ -52,7 +52,6 @@ |
net_log, |
net::NetLog::Source())), |
send_pending_(false), |
- receive_pending_(false), |
client_connected_(false), |
status_callback_(status_callback), |
weak_factory_(this) { |
@@ -85,18 +84,7 @@ |
NOTREACHED() << "Either local or remote address has to be defined."; |
} |
- ScheduleReceiveNextPacket(); |
-} |
- |
-void UdpTransport::ScheduleReceiveNextPacket() { |
- DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
- if (!packet_receiver_.is_null() && !receive_pending_) { |
- receive_pending_ = true; |
- io_thread_proxy_->PostTask(FROM_HERE, |
- base::Bind(&UdpTransport::ReceiveNextPacket, |
- weak_factory_.GetWeakPtr(), |
- net::ERR_IO_PENDING)); |
- } |
+ ReceiveNextPacket(net::ERR_IO_PENDING); |
} |
void UdpTransport::ReceiveNextPacket(int length_or_status) { |
@@ -116,18 +104,16 @@ |
&recv_addr_, |
base::Bind(&UdpTransport::ReceiveNextPacket, |
weak_factory_.GetWeakPtr())); |
- if (length_or_status == net::ERR_IO_PENDING) { |
- receive_pending_ = true; |
+ if (length_or_status == net::ERR_IO_PENDING) |
return; |
- } |
} |
// Note: At this point, either a packet is ready or an error has occurred. |
+ |
if (length_or_status < 0) { |
VLOG(1) << "Failed to receive packet: Status code is " |
- << length_or_status; |
+ << length_or_status << ". Stop receiving packets."; |
status_callback_.Run(TRANSPORT_SOCKET_ERROR); |
- receive_pending_ = false; |
return; |
} |
@@ -195,8 +181,6 @@ |
status_callback_.Run(TRANSPORT_SOCKET_ERROR); |
return true; |
} else { |
- // Successful send, re-start reading if needed. |
- ScheduleReceiveNextPacket(); |
return true; |
} |
} |
@@ -211,9 +195,6 @@ |
if (result < 0) { |
LOG(ERROR) << "Failed to send packet: " << result << "."; |
status_callback_.Run(TRANSPORT_SOCKET_ERROR); |
- } else { |
- // Successful send, re-start reading if needed. |
- ScheduleReceiveNextPacket(); |
} |
if (!cb.is_null()) { |