OLD | NEW |
1 // Copyright (c) 2009 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 #ifndef NET_SOCKET_TCP_PINGER_H_ | 5 #ifndef NET_SOCKET_TCP_PINGER_H_ |
6 #define NET_SOCKET_TCP_PINGER_H_ | 6 #define NET_SOCKET_TCP_PINGER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/dynamic_annotations.h" | 9 #include "base/dynamic_annotations.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 public: | 79 public: |
80 explicit Worker(const net::AddressList& addr) | 80 explicit Worker(const net::AddressList& addr) |
81 : event_(false, false), | 81 : event_(false, false), |
82 net_error_(ERR_IO_PENDING), | 82 net_error_(ERR_IO_PENDING), |
83 addr_(addr), | 83 addr_(addr), |
84 ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_(this, | 84 ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_(this, |
85 &net::TCPPinger::Worker::ConnectDone)) { | 85 &net::TCPPinger::Worker::ConnectDone)) { |
86 } | 86 } |
87 | 87 |
88 void DoConnect() { | 88 void DoConnect() { |
89 sock_.reset(new TCPClientSocket(addr_)); | 89 sock_.reset(new TCPClientSocket(addr_, NULL)); |
90 int rv = sock_->Connect(&connect_callback_, NULL); | 90 int rv = sock_->Connect(&connect_callback_); |
91 // Regardless of success or failure, if we're done now, | 91 // Regardless of success or failure, if we're done now, |
92 // signal the customer. | 92 // signal the customer. |
93 if (rv != ERR_IO_PENDING) | 93 if (rv != ERR_IO_PENDING) |
94 ConnectDone(rv); | 94 ConnectDone(rv); |
95 } | 95 } |
96 | 96 |
97 void DoDisconnect() { | 97 void DoDisconnect() { |
98 sock_.reset(); | 98 sock_.reset(); |
99 event_.Signal(); | 99 event_.Signal(); |
100 } | 100 } |
(...skipping 30 matching lines...) Expand all Loading... |
131 }; | 131 }; |
132 | 132 |
133 base::Thread io_thread_; | 133 base::Thread io_thread_; |
134 Worker* worker_; | 134 Worker* worker_; |
135 DISALLOW_COPY_AND_ASSIGN(TCPPinger); | 135 DISALLOW_COPY_AND_ASSIGN(TCPPinger); |
136 }; | 136 }; |
137 | 137 |
138 } // namespace net | 138 } // namespace net |
139 | 139 |
140 #endif // NET_SOCKET_TCP_PINGER_H_ | 140 #endif // NET_SOCKET_TCP_PINGER_H_ |
OLD | NEW |