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

Side by Side Diff: net/udp/udp_server_socket.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 | « net/udp/udp_server_socket.h ('k') | net/udp/udp_socket.h » ('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 (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_server_socket.h" 5 #include "net/udp/udp_server_socket.h"
6 6
7 #include "net/base/net_errors.h"
7 #include "net/base/rand_callback.h" 8 #include "net/base/rand_callback.h"
8 9
9 namespace net { 10 namespace net {
10 11
11 UDPServerSocket::UDPServerSocket(net::NetLog* net_log, 12 UDPServerSocket::UDPServerSocket(net::NetLog* net_log,
12 const net::NetLog::Source& source) 13 const net::NetLog::Source& source)
13 : socket_(DatagramSocket::DEFAULT_BIND, 14 : socket_(DatagramSocket::DEFAULT_BIND,
14 RandIntCallback(), 15 RandIntCallback(),
15 net_log, 16 net_log,
16 source) { 17 source),
18 allow_address_reuse_(false),
19 allow_broadcast_(false) {
17 } 20 }
18 21
19 UDPServerSocket::~UDPServerSocket() { 22 UDPServerSocket::~UDPServerSocket() {
20 } 23 }
21 24
22 int UDPServerSocket::Listen(const IPEndPoint& address) { 25 int UDPServerSocket::Listen(const IPEndPoint& address) {
26 int rv = socket_.Open(address.GetFamily());
27 if (rv != OK)
28 return rv;
29
30 if (allow_address_reuse_) {
31 rv = socket_.AllowAddressReuse();
32 if (rv != OK) {
33 socket_.Close();
34 return rv;
35 }
36 }
37
38 if (allow_broadcast_) {
39 rv = socket_.SetBroadcast(true);
40 if (rv != OK) {
41 socket_.Close();
42 return rv;
43 }
44 }
45
23 return socket_.Bind(address); 46 return socket_.Bind(address);
24 } 47 }
25 48
26 int UDPServerSocket::RecvFrom(IOBuffer* buf, 49 int UDPServerSocket::RecvFrom(IOBuffer* buf,
27 int buf_len, 50 int buf_len,
28 IPEndPoint* address, 51 IPEndPoint* address,
29 const CompletionCallback& callback) { 52 const CompletionCallback& callback) {
30 return socket_.RecvFrom(buf, buf_len, address, callback); 53 return socket_.RecvFrom(buf, buf_len, address, callback);
31 } 54 }
32 55
(...skipping 22 matching lines...) Expand all
55 78
56 int UDPServerSocket::GetLocalAddress(IPEndPoint* address) const { 79 int UDPServerSocket::GetLocalAddress(IPEndPoint* address) const {
57 return socket_.GetLocalAddress(address); 80 return socket_.GetLocalAddress(address);
58 } 81 }
59 82
60 const BoundNetLog& UDPServerSocket::NetLog() const { 83 const BoundNetLog& UDPServerSocket::NetLog() const {
61 return socket_.NetLog(); 84 return socket_.NetLog();
62 } 85 }
63 86
64 void UDPServerSocket::AllowAddressReuse() { 87 void UDPServerSocket::AllowAddressReuse() {
65 socket_.AllowAddressReuse(); 88 allow_address_reuse_ = true;
66 } 89 }
67 90
68 void UDPServerSocket::AllowBroadcast() { 91 void UDPServerSocket::AllowBroadcast() {
69 socket_.AllowBroadcast(); 92 allow_broadcast_ = true;
70 } 93 }
71 94
72 int UDPServerSocket::JoinGroup(const IPAddressNumber& group_address) const { 95 int UDPServerSocket::JoinGroup(const IPAddressNumber& group_address) const {
73 return socket_.JoinGroup(group_address); 96 return socket_.JoinGroup(group_address);
74 } 97 }
75 98
76 int UDPServerSocket::LeaveGroup(const IPAddressNumber& group_address) const { 99 int UDPServerSocket::LeaveGroup(const IPAddressNumber& group_address) const {
77 return socket_.LeaveGroup(group_address); 100 return socket_.LeaveGroup(group_address);
78 } 101 }
79 102
(...skipping 11 matching lines...) Expand all
91 114
92 int UDPServerSocket::SetDiffServCodePoint(DiffServCodePoint dscp) { 115 int UDPServerSocket::SetDiffServCodePoint(DiffServCodePoint dscp) {
93 return socket_.SetDiffServCodePoint(dscp); 116 return socket_.SetDiffServCodePoint(dscp);
94 } 117 }
95 118
96 void UDPServerSocket::DetachFromThread() { 119 void UDPServerSocket::DetachFromThread() {
97 socket_.DetachFromThread(); 120 socket_.DetachFromThread();
98 } 121 }
99 122
100 } // namespace net 123 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_server_socket.h ('k') | net/udp/udp_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698