| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "media/cast/net/udp_transport.h" |    5 #include "media/cast/net/udp_transport.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <string> |    8 #include <string> | 
|    9  |    9  | 
|   10 #include "base/bind.h" |   10 #include "base/bind.h" | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|   33                                                     addr1.address().end(), |   33                                                     addr1.address().end(), | 
|   34                                                     addr2.address().begin()); |   34                                                     addr2.address().begin()); | 
|   35 } |   35 } | 
|   36 }  // namespace |   36 }  // namespace | 
|   37  |   37  | 
|   38 UdpTransport::UdpTransport( |   38 UdpTransport::UdpTransport( | 
|   39     net::NetLog* net_log, |   39     net::NetLog* net_log, | 
|   40     const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, |   40     const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, | 
|   41     const net::IPEndPoint& local_end_point, |   41     const net::IPEndPoint& local_end_point, | 
|   42     const net::IPEndPoint& remote_end_point, |   42     const net::IPEndPoint& remote_end_point, | 
|   43     int32 send_buffer_size, |   43     int32_t send_buffer_size, | 
|   44     const CastTransportStatusCallback& status_callback) |   44     const CastTransportStatusCallback& status_callback) | 
|   45     : io_thread_proxy_(io_thread_proxy), |   45     : io_thread_proxy_(io_thread_proxy), | 
|   46       local_addr_(local_end_point), |   46       local_addr_(local_end_point), | 
|   47       remote_addr_(remote_end_point), |   47       remote_addr_(remote_end_point), | 
|   48       udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, |   48       udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, | 
|   49                                      net::RandIntCallback(), |   49                                      net::RandIntCallback(), | 
|   50                                      net_log, |   50                                      net_log, | 
|   51                                      net::NetLog::Source())), |   51                                      net::NetLog::Source())), | 
|   52       send_pending_(false), |   52       send_pending_(false), | 
|   53       receive_pending_(false), |   53       receive_pending_(false), | 
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  250   } |  250   } | 
|  251  |  251  | 
|  252   if (result == net::ERR_IO_PENDING) { |  252   if (result == net::ERR_IO_PENDING) { | 
|  253     send_pending_ = true; |  253     send_pending_ = true; | 
|  254     return false; |  254     return false; | 
|  255   } |  255   } | 
|  256   OnSent(buf, packet, base::Closure(), result); |  256   OnSent(buf, packet, base::Closure(), result); | 
|  257   return true; |  257   return true; | 
|  258 } |  258 } | 
|  259  |  259  | 
|  260 int64 UdpTransport::GetBytesSent() { |  260 int64_t UdpTransport::GetBytesSent() { | 
|  261   return bytes_sent_; |  261   return bytes_sent_; | 
|  262 } |  262 } | 
|  263  |  263  | 
|  264 void UdpTransport::OnSent(const scoped_refptr<net::IOBuffer>& buf, |  264 void UdpTransport::OnSent(const scoped_refptr<net::IOBuffer>& buf, | 
|  265                           PacketRef packet, |  265                           PacketRef packet, | 
|  266                           const base::Closure& cb, |  266                           const base::Closure& cb, | 
|  267                           int result) { |  267                           int result) { | 
|  268   DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |  268   DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); | 
|  269  |  269  | 
|  270   send_pending_ = false; |  270   send_pending_ = false; | 
|  271   if (result < 0) { |  271   if (result < 0) { | 
|  272     VLOG(1) << "Failed to send packet: " << result << "."; |  272     VLOG(1) << "Failed to send packet: " << result << "."; | 
|  273   } |  273   } | 
|  274   ScheduleReceiveNextPacket(); |  274   ScheduleReceiveNextPacket(); | 
|  275  |  275  | 
|  276   if (!cb.is_null()) { |  276   if (!cb.is_null()) { | 
|  277     cb.Run(); |  277     cb.Run(); | 
|  278   } |  278   } | 
|  279 } |  279 } | 
|  280  |  280  | 
|  281 }  // namespace cast |  281 }  // namespace cast | 
|  282 }  // namespace media |  282 }  // namespace media | 
| OLD | NEW |