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

Side by Side Diff: net/socket/tcp_client_socket_win.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/tcp_client_socket_libevent.cc ('k') | net/socket/tcp_server_socket_libevent.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_win.h" 5 #include "net/socket/tcp_client_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 if (current_address_index_ >= 0 || bind_address_.get()) { 376 if (current_address_index_ >= 0 || bind_address_.get()) {
377 // Cannot bind the socket if we are already connected or connecting. 377 // Cannot bind the socket if we are already connected or connecting.
378 return ERR_UNEXPECTED; 378 return ERR_UNEXPECTED;
379 } 379 }
380 380
381 SockaddrStorage storage; 381 SockaddrStorage storage;
382 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) 382 if (!address.ToSockAddr(storage.addr, &storage.addr_len))
383 return ERR_INVALID_ARGUMENT; 383 return ERR_INVALID_ARGUMENT;
384 384
385 // Create |bound_socket_| and try to bind it to |address|. 385 // Create |bound_socket_| and try to bind it to |address|.
386 int error = CreateSocket(address.GetFamily(), &bound_socket_); 386 int error = CreateSocket(address.GetSockAddrFamily(), &bound_socket_);
387 if (error) 387 if (error)
388 return MapSystemError(error); 388 return MapSystemError(error);
389 389
390 if (bind(bound_socket_, storage.addr, storage.addr_len)) { 390 if (bind(bound_socket_, storage.addr, storage.addr_len)) {
391 error = errno; 391 error = errno;
392 if (closesocket(bound_socket_) < 0) 392 if (closesocket(bound_socket_) < 0)
393 PLOG(ERROR) << "closesocket"; 393 PLOG(ERROR) << "closesocket";
394 bound_socket_ = INVALID_SOCKET; 394 bound_socket_ = INVALID_SOCKET;
395 return MapSystemError(error); 395 return MapSystemError(error);
396 } 396 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, 472 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT,
473 CreateNetLogIPEndPointCallback(&endpoint)); 473 CreateNetLogIPEndPointCallback(&endpoint));
474 474
475 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE; 475 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE;
476 476
477 if (bound_socket_ != INVALID_SOCKET) { 477 if (bound_socket_ != INVALID_SOCKET) {
478 DCHECK(bind_address_.get()); 478 DCHECK(bind_address_.get());
479 socket_ = bound_socket_; 479 socket_ = bound_socket_;
480 bound_socket_ = INVALID_SOCKET; 480 bound_socket_ = INVALID_SOCKET;
481 } else { 481 } else {
482 connect_os_error_ = CreateSocket(endpoint.GetFamily(), &socket_); 482 connect_os_error_ = CreateSocket(endpoint.GetSockAddrFamily(), &socket_);
483 if (connect_os_error_ != 0) 483 if (connect_os_error_ != 0)
484 return MapSystemError(connect_os_error_); 484 return MapSystemError(connect_os_error_);
485 485
486 if (bind_address_.get()) { 486 if (bind_address_.get()) {
487 SockaddrStorage storage; 487 SockaddrStorage storage;
488 if (!bind_address_->ToSockAddr(storage.addr, &storage.addr_len)) 488 if (!bind_address_->ToSockAddr(storage.addr, &storage.addr_len))
489 return ERR_INVALID_ARGUMENT; 489 return ERR_INVALID_ARGUMENT;
490 if (bind(socket_, storage.addr, storage.addr_len)) 490 if (bind(socket_, storage.addr, storage.addr_len))
491 return MapSystemError(errno); 491 return MapSystemError(errno);
492 } 492 }
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 core_->WatchForRead(); 1044 core_->WatchForRead();
1045 return; 1045 return;
1046 } 1046 }
1047 waiting_read_ = false; 1047 waiting_read_ = false;
1048 core_->read_iobuffer_ = NULL; 1048 core_->read_iobuffer_ = NULL;
1049 core_->read_buffer_length_ = 0; 1049 core_->read_buffer_length_ = 0;
1050 DoReadCallback(rv); 1050 DoReadCallback(rv);
1051 } 1051 }
1052 1052
1053 } // namespace net 1053 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | net/socket/tcp_server_socket_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698