OLD | NEW |
---|---|
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 "content/browser/renderer_host/p2p/socket_host_udp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 } else { | 102 } else { |
103 send_buffer_size_ = send_buffer_size; | 103 send_buffer_size_ = send_buffer_size; |
104 } | 104 } |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 bool P2PSocketHostUdp::Init(const net::IPEndPoint& local_address, | 108 bool P2PSocketHostUdp::Init(const net::IPEndPoint& local_address, |
109 const P2PHostAndIPEndPoint& remote_address) { | 109 const P2PHostAndIPEndPoint& remote_address) { |
110 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 110 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
111 | 111 |
112 #if defined(OS_WIN) | |
113 // If configured for finch experiment, use nonblocking IO. | |
114 if (base::FieldTrialList::FindFullName("WebRTC-UDPServerSocketAsync") == | |
Sergey Ulanov
2015/03/13 18:28:51
This is not a good name for the experiment: overla
John L. Miller
2015/03/23 14:11:27
Done.
John L. Miller
2015/03/23 14:11:28
Done.
| |
115 "Enabled") { | |
116 static_cast<UdpServerSocket *>(socket_.get())->UseNonBlockingIO(); | |
Sergey Ulanov
2015/03/13 18:28:51
You can avoid upcast if you put this in the constr
John L. Miller
2015/03/23 14:11:28
I'm nervous about changing the type when socket_ i
Sergey Ulanov
2015/03/25 17:50:28
I wasn't suggesting to change type of |socket_|. I
| |
117 } | |
118 #endif | |
119 | |
112 int result = socket_->Listen(local_address); | 120 int result = socket_->Listen(local_address); |
113 if (result < 0) { | 121 if (result < 0) { |
114 LOG(ERROR) << "bind() failed: " << result; | 122 LOG(ERROR) << "bind() failed: " << result; |
115 OnError(); | 123 OnError(); |
116 return false; | 124 return false; |
117 } | 125 } |
118 | 126 |
119 // Setting recv socket buffer size. | 127 // Setting recv socket buffer size. |
120 if (socket_->SetReceiveBufferSize(kRecvSocketBufferSize) != net::OK) { | 128 if (socket_->SetReceiveBufferSize(kRecvSocketBufferSize) != net::OK) { |
121 LOG(WARNING) << "Failed to set socket receive buffer size to " | 129 LOG(WARNING) << "Failed to set socket receive buffer size to " |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 case P2P_SOCKET_OPT_DSCP: | 379 case P2P_SOCKET_OPT_DSCP: |
372 return (net::OK == socket_->SetDiffServCodePoint( | 380 return (net::OK == socket_->SetDiffServCodePoint( |
373 static_cast<net::DiffServCodePoint>(value))) ? true : false; | 381 static_cast<net::DiffServCodePoint>(value))) ? true : false; |
374 default: | 382 default: |
375 NOTREACHED(); | 383 NOTREACHED(); |
376 return false; | 384 return false; |
377 } | 385 } |
378 } | 386 } |
379 | 387 |
380 } // namespace content | 388 } // namespace content |
OLD | NEW |