OLD | NEW |
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/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/profiler/scoped_tracker.h" | |
12 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
13 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
14 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
15 #include "net/log/net_log.h" | 14 #include "net/log/net_log.h" |
16 #include "net/socket/client_socket_handle.h" | 15 #include "net/socket/client_socket_handle.h" |
17 | 16 |
18 namespace net { | 17 namespace net { |
19 | 18 |
20 // Every SOCKS server requests a user-id from the client. It is optional | 19 // Every SOCKS server requests a user-id from the client. It is optional |
21 // and we send an empty string. | 20 // and we send an empty string. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 DCHECK_NE(ERR_IO_PENDING, result); | 223 DCHECK_NE(ERR_IO_PENDING, result); |
225 DCHECK(!user_callback_.is_null()); | 224 DCHECK(!user_callback_.is_null()); |
226 | 225 |
227 // Since Run() may result in Read being called, | 226 // Since Run() may result in Read being called, |
228 // clear user_callback_ up front. | 227 // clear user_callback_ up front. |
229 DVLOG(1) << "Finished setting up SOCKS handshake"; | 228 DVLOG(1) << "Finished setting up SOCKS handshake"; |
230 base::ResetAndReturn(&user_callback_).Run(result); | 229 base::ResetAndReturn(&user_callback_).Run(result); |
231 } | 230 } |
232 | 231 |
233 void SOCKSClientSocket::OnIOComplete(int result) { | 232 void SOCKSClientSocket::OnIOComplete(int result) { |
234 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. | |
235 tracked_objects::ScopedTracker tracking_profile( | |
236 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
237 "436634 SOCKSClientSocket::OnIOComplete")); | |
238 | |
239 DCHECK_NE(STATE_NONE, next_state_); | 233 DCHECK_NE(STATE_NONE, next_state_); |
240 int rv = DoLoop(result); | 234 int rv = DoLoop(result); |
241 if (rv != ERR_IO_PENDING) { | 235 if (rv != ERR_IO_PENDING) { |
242 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SOCKS_CONNECT, rv); | 236 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SOCKS_CONNECT, rv); |
243 DoCallback(rv); | 237 DoCallback(rv); |
244 } | 238 } |
245 } | 239 } |
246 | 240 |
247 void SOCKSClientSocket::OnReadWriteComplete(const CompletionCallback& callback, | 241 void SOCKSClientSocket::OnReadWriteComplete(const CompletionCallback& callback, |
248 int result) { | 242 int result) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 446 |
453 int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const { | 447 int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const { |
454 return transport_->socket()->GetPeerAddress(address); | 448 return transport_->socket()->GetPeerAddress(address); |
455 } | 449 } |
456 | 450 |
457 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { | 451 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { |
458 return transport_->socket()->GetLocalAddress(address); | 452 return transport_->socket()->GetLocalAddress(address); |
459 } | 453 } |
460 | 454 |
461 } // namespace net | 455 } // namespace net |
OLD | NEW |