OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_libevent.h" | 5 #include "net/socket/tcp_client_socket_libevent.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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 : socket_(kInvalidSocket), | 103 : socket_(kInvalidSocket), |
104 addresses_(addresses), | 104 addresses_(addresses), |
105 current_ai_(NULL), | 105 current_ai_(NULL), |
106 read_watcher_(this), | 106 read_watcher_(this), |
107 write_watcher_(this), | 107 write_watcher_(this), |
108 read_callback_(NULL), | 108 read_callback_(NULL), |
109 write_callback_(NULL), | 109 write_callback_(NULL), |
110 next_connect_state_(CONNECT_STATE_NONE), | 110 next_connect_state_(CONNECT_STATE_NONE), |
111 connect_os_error_(0), | 111 connect_os_error_(0), |
112 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) { | 112 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) { |
| 113 net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, NULL); |
113 } | 114 } |
114 | 115 |
115 TCPClientSocketLibevent::~TCPClientSocketLibevent() { | 116 TCPClientSocketLibevent::~TCPClientSocketLibevent() { |
116 Disconnect(); | 117 Disconnect(); |
117 net_log_.AddEvent(NetLog::TYPE_TCP_SOCKET_DONE, NULL); | 118 net_log_.EndEvent(NetLog::TYPE_SOCKET_ALIVE, NULL); |
118 } | 119 } |
119 | 120 |
120 int TCPClientSocketLibevent::Connect(CompletionCallback* callback) { | 121 int TCPClientSocketLibevent::Connect(CompletionCallback* callback) { |
121 DCHECK(CalledOnValidThread()); | 122 DCHECK(CalledOnValidThread()); |
122 | 123 |
123 // If already connected, then just return OK. | 124 // If already connected, then just return OK. |
124 if (socket_ != kInvalidSocket) | 125 if (socket_ != kInvalidSocket) |
125 return OK; | 126 return OK; |
126 | 127 |
127 DCHECK(!waiting_connect()); | 128 DCHECK(!waiting_connect()); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 int TCPClientSocketLibevent::GetPeerAddress(AddressList* address) const { | 499 int TCPClientSocketLibevent::GetPeerAddress(AddressList* address) const { |
499 DCHECK(CalledOnValidThread()); | 500 DCHECK(CalledOnValidThread()); |
500 DCHECK(address); | 501 DCHECK(address); |
501 if (!current_ai_) | 502 if (!current_ai_) |
502 return ERR_UNEXPECTED; | 503 return ERR_UNEXPECTED; |
503 address->Copy(current_ai_, false); | 504 address->Copy(current_ai_, false); |
504 return OK; | 505 return OK; |
505 } | 506 } |
506 | 507 |
507 } // namespace net | 508 } // namespace net |
OLD | NEW |