Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: media/cast/net/udp_transport.cc

Issue 654843007: Cast: Increase UDP socket send buffer size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: vlog to log(warning) Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/net/udp_transport.h ('k') | media/cast/net/udp_transport_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 addr1.address().end(), 35 addr1.address().end(),
36 addr2.address().begin()); 36 addr2.address().begin());
37 } 37 }
38 } // namespace 38 } // namespace
39 39
40 UdpTransport::UdpTransport( 40 UdpTransport::UdpTransport(
41 net::NetLog* net_log, 41 net::NetLog* net_log,
42 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, 42 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy,
43 const net::IPEndPoint& local_end_point, 43 const net::IPEndPoint& local_end_point,
44 const net::IPEndPoint& remote_end_point, 44 const net::IPEndPoint& remote_end_point,
45 int32 send_buffer_size,
45 const CastTransportStatusCallback& status_callback) 46 const CastTransportStatusCallback& status_callback)
46 : io_thread_proxy_(io_thread_proxy), 47 : io_thread_proxy_(io_thread_proxy),
47 local_addr_(local_end_point), 48 local_addr_(local_end_point),
48 remote_addr_(remote_end_point), 49 remote_addr_(remote_end_point),
49 udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, 50 udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND,
50 net::RandIntCallback(), 51 net::RandIntCallback(),
51 net_log, 52 net_log,
52 net::NetLog::Source())), 53 net::NetLog::Source())),
53 send_pending_(false), 54 send_pending_(false),
54 receive_pending_(false), 55 receive_pending_(false),
55 client_connected_(false), 56 client_connected_(false),
56 next_dscp_value_(net::DSCP_NO_CHANGE), 57 next_dscp_value_(net::DSCP_NO_CHANGE),
58 send_buffer_size_(send_buffer_size),
57 status_callback_(status_callback), 59 status_callback_(status_callback),
58 bytes_sent_(0), 60 bytes_sent_(0),
59 weak_factory_(this) { 61 weak_factory_(this) {
60 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point)); 62 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point));
61 } 63 }
62 64
63 UdpTransport::~UdpTransport() {} 65 UdpTransport::~UdpTransport() {}
64 66
65 void UdpTransport::StartReceiving( 67 void UdpTransport::StartReceiving(
66 const PacketReceiverCallback& packet_receiver) { 68 const PacketReceiverCallback& packet_receiver) {
(...skipping 11 matching lines...) Expand all
78 } else if (!IsEmpty(remote_addr_)) { 80 } else if (!IsEmpty(remote_addr_)) {
79 if (udp_socket_->Connect(remote_addr_) < 0) { 81 if (udp_socket_->Connect(remote_addr_) < 0) {
80 status_callback_.Run(TRANSPORT_SOCKET_ERROR); 82 status_callback_.Run(TRANSPORT_SOCKET_ERROR);
81 LOG(ERROR) << "Failed to connect to remote address."; 83 LOG(ERROR) << "Failed to connect to remote address.";
82 return; 84 return;
83 } 85 }
84 client_connected_ = true; 86 client_connected_ = true;
85 } else { 87 } else {
86 NOTREACHED() << "Either local or remote address has to be defined."; 88 NOTREACHED() << "Either local or remote address has to be defined.";
87 } 89 }
90 if (udp_socket_->SetSendBufferSize(send_buffer_size_) != net::OK) {
91 VLOG(1) << "Failed to set socket send buffer size.";
92 }
88 93
89 ScheduleReceiveNextPacket(); 94 ScheduleReceiveNextPacket();
90 } 95 }
91 96
92 void UdpTransport::SetDscp(net::DiffServCodePoint dscp) { 97 void UdpTransport::SetDscp(net::DiffServCodePoint dscp) {
93 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); 98 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
94 next_dscp_value_ = dscp; 99 next_dscp_value_ = dscp;
95 } 100 }
96 101
97 void UdpTransport::ScheduleReceiveNextPacket() { 102 void UdpTransport::ScheduleReceiveNextPacket() {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 227 }
223 228
224 void UdpTransport::OnSent(const scoped_refptr<net::IOBuffer>& buf, 229 void UdpTransport::OnSent(const scoped_refptr<net::IOBuffer>& buf,
225 PacketRef packet, 230 PacketRef packet,
226 const base::Closure& cb, 231 const base::Closure& cb,
227 int result) { 232 int result) {
228 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); 233 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
229 234
230 send_pending_ = false; 235 send_pending_ = false;
231 if (result < 0) { 236 if (result < 0) {
232 VLOG(1) << "Failed to send packet: " << result << "."; 237 LOG(WARNING) << "Failed to send packet: " << result << ".";
miu 2014/10/17 20:20:42 Not here! ;-) You meant to change line 91 instea
Alpha Left Google 2014/10/17 20:24:57 Doh I must be too sleepy.
233 } 238 }
234 ScheduleReceiveNextPacket(); 239 ScheduleReceiveNextPacket();
235 240
236 if (!cb.is_null()) { 241 if (!cb.is_null()) {
237 cb.Run(); 242 cb.Run();
238 } 243 }
239 } 244 }
240 245
241 } // namespace cast 246 } // namespace cast
242 } // namespace media 247 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/udp_transport.h ('k') | media/cast/net/udp_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698