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

Side by Side Diff: net/udp/udp_socket_libevent.cc

Issue 217573002: make SetReceiveBufferSize and SetSendBufferSize return net error codes (instead of bools) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: process error code in quic_stream_factory Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/udp/udp_socket_libevent.h" 5 #include "net/udp/udp_socket_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <net/if.h> 10 #include <net/if.h>
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 rv = DoBind(address); 309 rv = DoBind(address);
310 if (rv < 0) { 310 if (rv < 0) {
311 Close(); 311 Close();
312 return rv; 312 return rv;
313 } 313 }
314 local_address_.reset(); 314 local_address_.reset();
315 return rv; 315 return rv;
316 } 316 }
317 317
318 bool UDPSocketLibevent::SetReceiveBufferSize(int32 size) { 318 int UDPSocketLibevent::SetReceiveBufferSize(int32 size) {
319 DCHECK(CalledOnValidThread()); 319 DCHECK(CalledOnValidThread());
320 int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF, 320 int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF,
321 reinterpret_cast<const char*>(&size), sizeof(size)); 321 reinterpret_cast<const char*>(&size), sizeof(size));
322 DCHECK(!rv) << "Could not set socket receive buffer size: " << errno; 322 int last_error = errno;
323 return rv == 0; 323 DCHECK(!rv) << "Could not set socket receive buffer size: " << last_error;
324 return MapSystemError(last_error);
wtc 2014/03/29 13:30:12 This should be: return rv == 0 ? OK : MapSyste
jar (doing other things) 2014/04/01 23:50:39 Done.
324 } 325 }
325 326
326 bool UDPSocketLibevent::SetSendBufferSize(int32 size) { 327 int UDPSocketLibevent::SetSendBufferSize(int32 size) {
327 DCHECK(CalledOnValidThread()); 328 DCHECK(CalledOnValidThread());
328 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, 329 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
329 reinterpret_cast<const char*>(&size), sizeof(size)); 330 reinterpret_cast<const char*>(&size), sizeof(size));
330 DCHECK(!rv) << "Could not set socket send buffer size: " << errno; 331 int last_error = errno;
331 return rv == 0; 332 DCHECK(!rv) << "Could not set socket send buffer size: " << last_error;
333 return MapSystemError(last_error);
wtc 2014/03/29 13:30:12 This should be: return rv == 0 ? OK : MapSystemErr
jar (doing other things) 2014/04/01 23:50:39 Done.
332 } 334 }
333 335
334 void UDPSocketLibevent::AllowAddressReuse() { 336 void UDPSocketLibevent::AllowAddressReuse() {
335 DCHECK(CalledOnValidThread()); 337 DCHECK(CalledOnValidThread());
336 DCHECK(!is_connected()); 338 DCHECK(!is_connected());
337 339
338 socket_options_ |= SOCKET_OPTION_REUSE_ADDRESS; 340 socket_options_ |= SOCKET_OPTION_REUSE_ADDRESS;
339 } 341 }
340 342
341 void UDPSocketLibevent::AllowBroadcast() { 343 void UDPSocketLibevent::AllowBroadcast() {
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 return MapSystemError(errno); 767 return MapSystemError(errno);
766 768
767 return OK; 769 return OK;
768 } 770 }
769 771
770 void UDPSocketLibevent::DetachFromThread() { 772 void UDPSocketLibevent::DetachFromThread() {
771 base::NonThreadSafe::DetachFromThread(); 773 base::NonThreadSafe::DetachFromThread();
772 } 774 }
773 775
774 } // namespace net 776 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698