1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/curvecp/curvecp_client_socket.h"
#include "net/curvecp/messenger.h"
namespace net {
CurveCPClientSocket::CurveCPClientSocket(const AddressList& addresses,
net::NetLog* net_log,
const net::NetLog::Source& source)
: addresses_(addresses),
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)),
messenger_(&packetizer_) {
}
CurveCPClientSocket::~CurveCPClientSocket() {
}
int CurveCPClientSocket::Connect(const CompletionCallback& callback) {
return packetizer_.Connect(addresses_, &messenger_, callback);
}
void CurveCPClientSocket::Disconnect() {
// TODO(mbelshe): DCHECK that we're connected.
// Record the ConnectionKey so that we can disconnect it properly.
// Do we need a close() on the messenger?
// packetizer_.Close();
}
bool CurveCPClientSocket::IsConnected() const {
// TODO(mbelshe): return packetizer_.IsConnected();
return false;
}
bool CurveCPClientSocket::IsConnectedAndIdle() const {
// TODO(mbelshe): return packetizer_.IsConnectedAndIdle();
return false;
}
int CurveCPClientSocket::GetPeerAddress(IPEndPoint* address) const {
IPEndPoint endpoint;
int rv = packetizer_.GetPeerAddress(&endpoint);
if (rv < 0)
return rv;
*address = endpoint;
return OK;
}
int CurveCPClientSocket::GetLocalAddress(IPEndPoint* address) const {
NOTIMPLEMENTED();
return ERR_FAILED;
}
const BoundNetLog& CurveCPClientSocket::NetLog() const {
return net_log_;
}
void CurveCPClientSocket::SetSubresourceSpeculation() {
// This is ridiculous.
}
void CurveCPClientSocket::SetOmniboxSpeculation() {
// This is ridiculous.
}
bool CurveCPClientSocket::WasEverUsed() const {
// This is ridiculous.
return true;
}
bool CurveCPClientSocket::UsingTCPFastOpen() const {
// This is ridiculous.
return false;
}
int64 CurveCPClientSocket::NumBytesRead() const {
return -1;
}
base::TimeDelta CurveCPClientSocket::GetConnectTimeMicros() const {
return base::TimeDelta::FromMicroseconds(-1);
}
NextProto CurveCPClientSocket::GetNegotiatedProtocol() const {
return kProtoUnknown;
}
int CurveCPClientSocket::Read(IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) {
return messenger_.Read(buf, buf_len, callback);
}
int CurveCPClientSocket::Write(IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) {
return messenger_.Write(buf, buf_len, callback);
}
bool CurveCPClientSocket::SetReceiveBufferSize(int32 size) {
return true;
}
bool CurveCPClientSocket::SetSendBufferSize(int32 size) {
return true;
}
} // namespace net
|