| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/ip_endpoint.h" | 5 #include "net/base/ip_endpoint.h" |
| 6 #include "net/base/net_errors.h" | 6 #include "net/base/net_errors.h" |
| 7 #include "net/base/sys_addrinfo.h" | 7 #include "net/base/sys_addrinfo.h" |
| 8 #include "net/curvecp/curvecp_client_socket.h" | 8 #include "net/curvecp/curvecp_client_socket.h" |
| 9 #include "net/curvecp/messenger.h" | 9 #include "net/curvecp/messenger.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 CurveCPClientSocket::CurveCPClientSocket(const AddressList& addresses, | 13 CurveCPClientSocket::CurveCPClientSocket(const AddressList& addresses, |
| 14 net::NetLog* net_log, | 14 net::NetLog* net_log, |
| 15 const net::NetLog::Source& source) | 15 const net::NetLog::Source& source) |
| 16 : addresses_(addresses), | 16 : addresses_(addresses), |
| 17 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)), | 17 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)), |
| 18 messenger_(&packetizer_) { | 18 messenger_(&packetizer_) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 CurveCPClientSocket::~CurveCPClientSocket() { | 21 CurveCPClientSocket::~CurveCPClientSocket() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 int CurveCPClientSocket::Connect(OldCompletionCallback* callback) { | 24 int CurveCPClientSocket::Connect(const CompletionCallback& callback) { |
| 25 return packetizer_.Connect(addresses_, &messenger_, callback); | 25 return packetizer_.Connect(addresses_, &messenger_, callback); |
| 26 } | 26 } |
| 27 | 27 |
| 28 int CurveCPClientSocket::Connect(const net::CompletionCallback& callback) { | |
| 29 return packetizer_.Connect(addresses_, &messenger_, callback); | |
| 30 } | |
| 31 | |
| 32 void CurveCPClientSocket::Disconnect() { | 28 void CurveCPClientSocket::Disconnect() { |
| 33 // TODO(mbelshe): DCHECK that we're connected. | 29 // TODO(mbelshe): DCHECK that we're connected. |
| 34 // Record the ConnectionKey so that we can disconnect it properly. | 30 // Record the ConnectionKey so that we can disconnect it properly. |
| 35 // Do we need a close() on the messenger? | 31 // Do we need a close() on the messenger? |
| 36 // packetizer_.Close(); | 32 // packetizer_.Close(); |
| 37 } | 33 } |
| 38 | 34 |
| 39 bool CurveCPClientSocket::IsConnected() const { | 35 bool CurveCPClientSocket::IsConnected() const { |
| 40 // TODO(mbelshe): return packetizer_.IsConnected(); | 36 // TODO(mbelshe): return packetizer_.IsConnected(); |
| 41 return false; | 37 return false; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 int64 CurveCPClientSocket::NumBytesRead() const { | 91 int64 CurveCPClientSocket::NumBytesRead() const { |
| 96 return -1; | 92 return -1; |
| 97 } | 93 } |
| 98 | 94 |
| 99 base::TimeDelta CurveCPClientSocket::GetConnectTimeMicros() const { | 95 base::TimeDelta CurveCPClientSocket::GetConnectTimeMicros() const { |
| 100 return base::TimeDelta::FromMicroseconds(-1); | 96 return base::TimeDelta::FromMicroseconds(-1); |
| 101 } | 97 } |
| 102 | 98 |
| 103 int CurveCPClientSocket::Read(IOBuffer* buf, | 99 int CurveCPClientSocket::Read(IOBuffer* buf, |
| 104 int buf_len, | 100 int buf_len, |
| 105 OldCompletionCallback* callback) { | |
| 106 return messenger_.Read(buf, buf_len, callback); | |
| 107 } | |
| 108 int CurveCPClientSocket::Read(IOBuffer* buf, | |
| 109 int buf_len, | |
| 110 const CompletionCallback& callback) { | 101 const CompletionCallback& callback) { |
| 111 return messenger_.Read(buf, buf_len, callback); | 102 return messenger_.Read(buf, buf_len, callback); |
| 112 } | 103 } |
| 113 | 104 |
| 114 int CurveCPClientSocket::Write(IOBuffer* buf, | 105 int CurveCPClientSocket::Write(IOBuffer* buf, |
| 115 int buf_len, | 106 int buf_len, |
| 116 OldCompletionCallback* callback) { | 107 const CompletionCallback& callback) { |
| 117 return messenger_.Write(buf, buf_len, callback); | 108 return messenger_.Write(buf, buf_len, callback); |
| 118 } | 109 } |
| 119 | 110 |
| 120 bool CurveCPClientSocket::SetReceiveBufferSize(int32 size) { | 111 bool CurveCPClientSocket::SetReceiveBufferSize(int32 size) { |
| 121 return true; | 112 return true; |
| 122 } | 113 } |
| 123 | 114 |
| 124 bool CurveCPClientSocket::SetSendBufferSize(int32 size) { | 115 bool CurveCPClientSocket::SetSendBufferSize(int32 size) { |
| 125 return true; | 116 return true; |
| 126 } | 117 } |
| 127 | 118 |
| 128 } // namespace net | 119 } // namespace net |
| OLD | NEW |