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

Side by Side Diff: net/socket/tcp_client_socket_libevent.cc

Issue 11528012: [net] Make IPEndPoint::GetFamily() return AddressFamily and add GetSockAddrFamily() to be used when… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update uses of GetFamily in net/dns/ Created 8 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/socks_client_socket.cc ('k') | net/socket/tcp_client_socket_win.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 (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/socket/tcp_client_socket.h" 5 #include "net/socket/tcp_client_socket.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 <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Cannot bind the socket if we are already bound connected or 174 // Cannot bind the socket if we are already bound connected or
175 // connecting. 175 // connecting.
176 return ERR_UNEXPECTED; 176 return ERR_UNEXPECTED;
177 } 177 }
178 178
179 SockaddrStorage storage; 179 SockaddrStorage storage;
180 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) 180 if (!address.ToSockAddr(storage.addr, &storage.addr_len))
181 return ERR_INVALID_ARGUMENT; 181 return ERR_INVALID_ARGUMENT;
182 182
183 // Create |bound_socket_| and try to bind it to |address|. 183 // Create |bound_socket_| and try to bind it to |address|.
184 int error = CreateSocket(address.GetFamily(), &bound_socket_); 184 int error = CreateSocket(address.GetSockAddrFamily(), &bound_socket_);
185 if (error) 185 if (error)
186 return MapSystemError(error); 186 return MapSystemError(error);
187 187
188 if (HANDLE_EINTR(bind(bound_socket_, storage.addr, storage.addr_len))) { 188 if (HANDLE_EINTR(bind(bound_socket_, storage.addr, storage.addr_len))) {
189 error = errno; 189 error = errno;
190 if (HANDLE_EINTR(close(bound_socket_)) < 0) 190 if (HANDLE_EINTR(close(bound_socket_)) < 0)
191 PLOG(ERROR) << "close"; 191 PLOG(ERROR) << "close";
192 bound_socket_ = kInvalidSocket; 192 bound_socket_ = kInvalidSocket;
193 return MapSystemError(error); 193 return MapSystemError(error);
194 } 194 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 CreateNetLogIPEndPointCallback(&endpoint)); 271 CreateNetLogIPEndPointCallback(&endpoint));
272 272
273 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE; 273 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE;
274 274
275 if (bound_socket_ != kInvalidSocket) { 275 if (bound_socket_ != kInvalidSocket) {
276 DCHECK(bind_address_.get()); 276 DCHECK(bind_address_.get());
277 socket_ = bound_socket_; 277 socket_ = bound_socket_;
278 bound_socket_ = kInvalidSocket; 278 bound_socket_ = kInvalidSocket;
279 } else { 279 } else {
280 // Create a non-blocking socket. 280 // Create a non-blocking socket.
281 connect_os_error_ = CreateSocket(endpoint.GetFamily(), &socket_); 281 connect_os_error_ = CreateSocket(endpoint.GetSockAddrFamily(), &socket_);
282 if (connect_os_error_) 282 if (connect_os_error_)
283 return MapSystemError(connect_os_error_); 283 return MapSystemError(connect_os_error_);
284 284
285 if (bind_address_.get()) { 285 if (bind_address_.get()) {
286 SockaddrStorage storage; 286 SockaddrStorage storage;
287 if (!bind_address_->ToSockAddr(storage.addr, &storage.addr_len)) 287 if (!bind_address_->ToSockAddr(storage.addr, &storage.addr_len))
288 return ERR_INVALID_ARGUMENT; 288 return ERR_INVALID_ARGUMENT;
289 if (HANDLE_EINTR(bind(socket_, storage.addr, storage.addr_len))) 289 if (HANDLE_EINTR(bind(socket_, storage.addr, storage.addr_len)))
290 return MapSystemError(errno); 290 return MapSystemError(errno);
291 } 291 }
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 783
784 NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { 784 NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const {
785 return kProtoUnknown; 785 return kProtoUnknown;
786 } 786 }
787 787
788 bool TCPClientSocketLibevent::GetSSLInfo(SSLInfo* ssl_info) { 788 bool TCPClientSocketLibevent::GetSSLInfo(SSLInfo* ssl_info) {
789 return false; 789 return false;
790 } 790 }
791 791
792 } // namespace net 792 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socks_client_socket.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698