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_win.h" | 5 #include "net/socket/tcp_client_socket_win.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory_debug.h" | 9 #include "base/memory_debug.h" |
10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 : socket_(INVALID_SOCKET), | 260 : socket_(INVALID_SOCKET), |
261 addresses_(addresses), | 261 addresses_(addresses), |
262 current_ai_(NULL), | 262 current_ai_(NULL), |
263 waiting_read_(false), | 263 waiting_read_(false), |
264 waiting_write_(false), | 264 waiting_write_(false), |
265 read_callback_(NULL), | 265 read_callback_(NULL), |
266 write_callback_(NULL), | 266 write_callback_(NULL), |
267 next_connect_state_(CONNECT_STATE_NONE), | 267 next_connect_state_(CONNECT_STATE_NONE), |
268 connect_os_error_(0), | 268 connect_os_error_(0), |
269 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) { | 269 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) { |
| 270 net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, NULL); |
270 EnsureWinsockInit(); | 271 EnsureWinsockInit(); |
271 } | 272 } |
272 | 273 |
273 TCPClientSocketWin::~TCPClientSocketWin() { | 274 TCPClientSocketWin::~TCPClientSocketWin() { |
274 Disconnect(); | 275 Disconnect(); |
275 net_log_.AddEvent(NetLog::TYPE_TCP_SOCKET_DONE, NULL); | 276 net_log_.EndEvent(NetLog::TYPE_SOCKET_ALIVE, NULL); |
276 } | 277 } |
277 | 278 |
278 int TCPClientSocketWin::Connect(CompletionCallback* callback) { | 279 int TCPClientSocketWin::Connect(CompletionCallback* callback) { |
279 DCHECK(CalledOnValidThread()); | 280 DCHECK(CalledOnValidThread()); |
280 | 281 |
281 // If already connected, then just return OK. | 282 // If already connected, then just return OK. |
282 if (socket_ != INVALID_SOCKET) | 283 if (socket_ != INVALID_SOCKET) |
283 return OK; | 284 return OK; |
284 | 285 |
285 static StatsCounter connects("tcp.connect"); | 286 static StatsCounter connects("tcp.connect"); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 } else { | 768 } else { |
768 net_log_.AddEvent(NetLog::TYPE_SOCKET_BYTES_SENT, | 769 net_log_.AddEvent(NetLog::TYPE_SOCKET_BYTES_SENT, |
769 new NetLogIntegerParameter("num_bytes", rv)); | 770 new NetLogIntegerParameter("num_bytes", rv)); |
770 } | 771 } |
771 } | 772 } |
772 core_->write_iobuffer_ = NULL; | 773 core_->write_iobuffer_ = NULL; |
773 DoWriteCallback(rv); | 774 DoWriteCallback(rv); |
774 } | 775 } |
775 | 776 |
776 } // namespace net | 777 } // namespace net |
OLD | NEW |