Chromium Code Reviews| Index: media/cast/net/udp_transport.cc |
| diff --git a/media/cast/net/udp_transport.cc b/media/cast/net/udp_transport.cc |
| index f36b03444dbf59dca08e0b6e8d2d85b5c687b85d..95a8997b22b6c595ae07890baca2eb5c046f1979 100644 |
| --- a/media/cast/net/udp_transport.cc |
| +++ b/media/cast/net/udp_transport.cc |
| @@ -75,6 +75,7 @@ void UdpTransport::StartReceiving( |
| udp_socket_->AllowAddressReuse() < 0 || |
| udp_socket_->Bind(local_addr_) < 0) { |
| udp_socket_->Close(); |
| + udp_socket_.reset(); |
|
Alpha Left Google
2015/02/25 20:37:28
Why changes in this file?
hubbe
2015/02/28 00:17:12
Moved to separate cl.
|
| status_callback_.Run(TRANSPORT_SOCKET_ERROR); |
| LOG(ERROR) << "Failed to bind local address."; |
| return; |
| @@ -84,6 +85,7 @@ void UdpTransport::StartReceiving( |
| udp_socket_->AllowAddressReuse() < 0 || |
| udp_socket_->Connect(remote_addr_) < 0) { |
| udp_socket_->Close(); |
| + udp_socket_.reset(); |
| status_callback_.Run(TRANSPORT_SOCKET_ERROR); |
| LOG(ERROR) << "Failed to connect to remote address."; |
| return; |
| @@ -113,6 +115,8 @@ void UdpTransport::SetDscp(net::DiffServCodePoint dscp) { |
| #if defined(OS_WIN) |
| void UdpTransport::UseNonBlockingIO() { |
| DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
| + if (!udp_socket_) |
| + return; |
| udp_socket_->UseNonBlockingIO(); |
| } |
| #endif |
| @@ -133,6 +137,8 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) { |
| if (packet_receiver_.is_null()) |
| return; |
| + if (!udp_socket_) |
| + return; |
| // Loop while UdpSocket is delivering data synchronously. When it responds |
| // with a "pending" status, break and expect this method to be called back in |
| @@ -189,6 +195,8 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) { |
| bool UdpTransport::SendPacket(PacketRef packet, const base::Closure& cb) { |
| DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
| + if (!udp_socket_) |
| + return true; |
| // Increase byte count no matter the packet was sent or dropped. |
| bytes_sent_ += packet->data.size(); |