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

Side by Side Diff: webrtc/p2p/base/basicpacketsocketfactory.cc

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Comment fixes Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( 107 AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket(
108 const SocketAddress& local_address, const SocketAddress& remote_address, 108 const SocketAddress& local_address, const SocketAddress& remote_address,
109 const ProxyInfo& proxy_info, const std::string& user_agent, int opts) { 109 const ProxyInfo& proxy_info, const std::string& user_agent, int opts) {
110 AsyncSocket* socket = 110 AsyncSocket* socket =
111 socket_factory()->CreateAsyncSocket(local_address.family(), SOCK_STREAM); 111 socket_factory()->CreateAsyncSocket(local_address.family(), SOCK_STREAM);
112 if (!socket) { 112 if (!socket) {
113 return NULL; 113 return NULL;
114 } 114 }
115 115
116 if (BindSocket(socket, local_address, 0, 0) < 0) { 116 if (BindSocket(socket, local_address, 0, 0) < 0) {
117 LOG(LS_ERROR) << "TCP bind failed with error " 117 // Allow BindSocket to fail if we're binding to the ANY address anyway. The
pthatcher1 2017/06/13 19:52:50 Not sure what "anyway" adds to the end of the sent
Taylor Brandstetter 2017/06/13 22:11:17 Rephrased comment.
118 << socket->GetError(); 118 // socket will be bound when we call Connect() instead.
119 delete socket; 119 if (local_address.IsAnyIP()) {
120 return NULL; 120 LOG(LS_WARNING) << "TCP bind failed with error " << socket->GetError()
121 << "; ignoring since socket is using 'any' address.";
pthatcher1 2017/06/13 19:52:49 Can you use an early return and then leave the res
Taylor Brandstetter 2017/06/13 22:11:17 I knew you would ask for an early return here. :)
122 } else {
123 LOG(LS_ERROR) << "TCP bind failed with error " << socket->GetError();
124 delete socket;
125 return NULL;
126 }
121 } 127 }
122 128
123 // If using a proxy, wrap the socket in a proxy socket. 129 // If using a proxy, wrap the socket in a proxy socket.
124 if (proxy_info.type == PROXY_SOCKS5) { 130 if (proxy_info.type == PROXY_SOCKS5) {
125 socket = new AsyncSocksProxySocket( 131 socket = new AsyncSocksProxySocket(
126 socket, proxy_info.address, proxy_info.username, proxy_info.password); 132 socket, proxy_info.address, proxy_info.username, proxy_info.password);
127 } else if (proxy_info.type == PROXY_HTTPS) { 133 } else if (proxy_info.type == PROXY_HTTPS) {
128 socket = 134 socket =
129 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address, 135 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address,
130 proxy_info.username, proxy_info.password); 136 proxy_info.username, proxy_info.password);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 SocketFactory* BasicPacketSocketFactory::socket_factory() { 212 SocketFactory* BasicPacketSocketFactory::socket_factory() {
207 if (thread_) { 213 if (thread_) {
208 RTC_DCHECK(thread_ == Thread::Current()); 214 RTC_DCHECK(thread_ == Thread::Current());
209 return thread_->socketserver(); 215 return thread_->socketserver();
210 } else { 216 } else {
211 return socket_factory_; 217 return socket_factory_;
212 } 218 }
213 } 219 }
214 220
215 } // namespace rtc 221 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698