OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 result = socket_->Bind(*bind_address_); | 134 result = socket_->Bind(*bind_address_); |
135 if (result != OK) { | 135 if (result != OK) { |
136 socket_->Close(); | 136 socket_->Close(); |
137 return result; | 137 return result; |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 // |socket_| is owned by this class and the callback won't be run once | 142 // |socket_| is owned by this class and the callback won't be run once |
143 // |socket_| is gone. Therefore, it is safe to use base::Unretained() here. | 143 // |socket_| is gone. Therefore, it is safe to use base::Unretained() here. |
144 return socket_->Connect(endpoint, | 144 return socket_->Connect( |
145 base::Bind(&TCPClientSocket::DidCompleteConnect, | 145 endpoint, |
146 base::Unretained(this))); | 146 base::Bind(&TCPClientSocket::DidCompleteConnect, base::Unretained(this))); |
147 } | 147 } |
148 | 148 |
149 int TCPClientSocket::DoConnectComplete(int result) { | 149 int TCPClientSocket::DoConnectComplete(int result) { |
150 if (result == OK) { | 150 if (result == OK) { |
151 use_history_.set_was_ever_connected(); | 151 use_history_.set_was_ever_connected(); |
152 return OK; // Done! | 152 return OK; // Done! |
153 } | 153 } |
154 | 154 |
155 // Close whatever partially connected socket we currently have. | 155 // Close whatever partially connected socket we currently have. |
156 DoDisconnect(); | 156 DoDisconnect(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 use_history_.set_was_used_to_convey_data(); | 267 use_history_.set_was_used_to_convey_data(); |
268 | 268 |
269 return result; | 269 return result; |
270 } | 270 } |
271 | 271 |
272 int TCPClientSocket::SetReceiveBufferSize(int32 size) { | 272 int TCPClientSocket::SetReceiveBufferSize(int32 size) { |
273 return socket_->SetReceiveBufferSize(size); | 273 return socket_->SetReceiveBufferSize(size); |
274 } | 274 } |
275 | 275 |
276 int TCPClientSocket::SetSendBufferSize(int32 size) { | 276 int TCPClientSocket::SetSendBufferSize(int32 size) { |
277 return socket_->SetSendBufferSize(size); | 277 return socket_->SetSendBufferSize(size); |
278 } | 278 } |
279 | 279 |
280 bool TCPClientSocket::SetKeepAlive(bool enable, int delay) { | 280 bool TCPClientSocket::SetKeepAlive(bool enable, int delay) { |
281 return socket_->SetKeepAlive(enable, delay); | 281 return socket_->SetKeepAlive(enable, delay); |
282 } | 282 } |
283 | 283 |
284 bool TCPClientSocket::SetNoDelay(bool no_delay) { | 284 bool TCPClientSocket::SetNoDelay(bool no_delay) { |
285 return socket_->SetNoDelay(no_delay); | 285 return socket_->SetNoDelay(no_delay); |
286 } | 286 } |
287 | 287 |
(...skipping 23 matching lines...) Expand all Loading... |
311 int result = socket_->Open(family); | 311 int result = socket_->Open(family); |
312 if (result != OK) | 312 if (result != OK) |
313 return result; | 313 return result; |
314 | 314 |
315 socket_->SetDefaultOptionsForClient(); | 315 socket_->SetDefaultOptionsForClient(); |
316 | 316 |
317 return OK; | 317 return OK; |
318 } | 318 } |
319 | 319 |
320 } // namespace net | 320 } // namespace net |
OLD | NEW |