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

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

Issue 721273002: Remove timing limitation to set Broadcast, ReceiveBuffer, and SendBuffer options from UDPSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « extensions/browser/api/socket/udp_socket.cc ('k') | media/cast/test/utility/net_utility.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point)); 62 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point));
63 } 63 }
64 64
65 UdpTransport::~UdpTransport() {} 65 UdpTransport::~UdpTransport() {}
66 66
67 void UdpTransport::StartReceiving( 67 void UdpTransport::StartReceiving(
68 const PacketReceiverCallback& packet_receiver) { 68 const PacketReceiverCallback& packet_receiver) {
69 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); 69 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
70 70
71 packet_receiver_ = packet_receiver; 71 packet_receiver_ = packet_receiver;
72 udp_socket_->AllowAddressReuse();
73 udp_socket_->SetMulticastLoopbackMode(true); 72 udp_socket_->SetMulticastLoopbackMode(true);
74 if (!IsEmpty(local_addr_)) { 73 if (!IsEmpty(local_addr_)) {
75 if (udp_socket_->Bind(local_addr_) < 0) { 74 if (udp_socket_->Open(local_addr_.GetFamily()) < 0 ||
75 udp_socket_->AllowAddressReuse() < 0 ||
76 udp_socket_->Bind(local_addr_) < 0) {
77 udp_socket_->Close();
76 status_callback_.Run(TRANSPORT_SOCKET_ERROR); 78 status_callback_.Run(TRANSPORT_SOCKET_ERROR);
77 LOG(ERROR) << "Failed to bind local address."; 79 LOG(ERROR) << "Failed to bind local address.";
78 return; 80 return;
79 } 81 }
80 } else if (!IsEmpty(remote_addr_)) { 82 } else if (!IsEmpty(remote_addr_)) {
81 if (udp_socket_->Connect(remote_addr_) < 0) { 83 if (udp_socket_->Open(remote_addr_.GetFamily()) < 0 ||
84 udp_socket_->AllowAddressReuse() < 0 ||
85 udp_socket_->Connect(remote_addr_) < 0) {
86 udp_socket_->Close();
82 status_callback_.Run(TRANSPORT_SOCKET_ERROR); 87 status_callback_.Run(TRANSPORT_SOCKET_ERROR);
83 LOG(ERROR) << "Failed to connect to remote address."; 88 LOG(ERROR) << "Failed to connect to remote address.";
84 return; 89 return;
85 } 90 }
86 client_connected_ = true; 91 client_connected_ = true;
87 } else { 92 } else {
88 NOTREACHED() << "Either local or remote address has to be defined."; 93 NOTREACHED() << "Either local or remote address has to be defined.";
89 } 94 }
90 if (udp_socket_->SetSendBufferSize(send_buffer_size_) != net::OK) { 95 if (udp_socket_->SetSendBufferSize(send_buffer_size_) != net::OK) {
91 LOG(WARNING) << "Failed to set socket send buffer size."; 96 LOG(WARNING) << "Failed to set socket send buffer size.";
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 243 }
239 ScheduleReceiveNextPacket(); 244 ScheduleReceiveNextPacket();
240 245
241 if (!cb.is_null()) { 246 if (!cb.is_null()) {
242 cb.Run(); 247 cb.Run();
243 } 248 }
244 } 249 }
245 250
246 } // namespace cast 251 } // namespace cast
247 } // namespace media 252 } // namespace media
OLDNEW
« no previous file with comments | « extensions/browser/api/socket/udp_socket.cc ('k') | media/cast/test/utility/net_utility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698