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
3 // found in the LICENSE file.
5 #include "net/base/ip_endpoint.h"
6 #include "net/base/net_errors.h"
7 #include "net/curvecp/curvecp_client_socket.h"
8 #include "net/curvecp/messenger.h"
12 CurveCPClientSocket::CurveCPClientSocket(const AddressList
& addresses
,
14 const net::NetLog::Source
& source
)
15 : addresses_(addresses
),
16 net_log_(BoundNetLog::Make(net_log
, NetLog::SOURCE_SOCKET
)),
17 messenger_(&packetizer_
) {
20 CurveCPClientSocket::~CurveCPClientSocket() {
23 int CurveCPClientSocket::Connect(const CompletionCallback
& callback
) {
24 return packetizer_
.Connect(addresses_
, &messenger_
, callback
);
27 void CurveCPClientSocket::Disconnect() {
28 // TODO(mbelshe): DCHECK that we're connected.
29 // Record the ConnectionKey so that we can disconnect it properly.
30 // Do we need a close() on the messenger?
31 // packetizer_.Close();
34 bool CurveCPClientSocket::IsConnected() const {
35 // TODO(mbelshe): return packetizer_.IsConnected();
39 bool CurveCPClientSocket::IsConnectedAndIdle() const {
40 // TODO(mbelshe): return packetizer_.IsConnectedAndIdle();
44 int CurveCPClientSocket::GetPeerAddress(AddressList
* address
) const {
46 int rv
= packetizer_
.GetPeerAddress(&endpoint
);
49 *address
= AddressList(endpoint
);
53 int CurveCPClientSocket::GetLocalAddress(IPEndPoint
* address
) const {
58 const BoundNetLog
& CurveCPClientSocket::NetLog() const {
62 void CurveCPClientSocket::SetSubresourceSpeculation() {
63 // This is ridiculous.
66 void CurveCPClientSocket::SetOmniboxSpeculation() {
67 // This is ridiculous.
70 bool CurveCPClientSocket::WasEverUsed() const {
71 // This is ridiculous.
75 bool CurveCPClientSocket::UsingTCPFastOpen() const {
76 // This is ridiculous.
80 int64
CurveCPClientSocket::NumBytesRead() const {
84 base::TimeDelta
CurveCPClientSocket::GetConnectTimeMicros() const {
85 return base::TimeDelta::FromMicroseconds(-1);
88 NextProto
CurveCPClientSocket::GetNegotiatedProtocol() const {
92 int CurveCPClientSocket::Read(IOBuffer
* buf
,
94 const CompletionCallback
& callback
) {
95 return messenger_
.Read(buf
, buf_len
, callback
);
98 int CurveCPClientSocket::Write(IOBuffer
* buf
,
100 const CompletionCallback
& callback
) {
101 return messenger_
.Write(buf
, buf_len
, callback
);
104 bool CurveCPClientSocket::SetReceiveBufferSize(int32 size
) {
108 bool CurveCPClientSocket::SetSendBufferSize(int32 size
) {