summaryrefslogtreecommitdiffstats
path: root/net/curvecp/curvecp_client_socket.h
blob: 80734b725a415a4b84edf0884fd37c00637c2f99 (plain)
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
// 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.

#ifndef NET_CURVECP_CURVECP_CLIENT_SOCKET_H_
#define NET_CURVECP_CURVECP_CLIENT_SOCKET_H_

#include "base/compiler_specific.h"
#include "net/base/completion_callback.h"
#include "net/curvecp/client_packetizer.h"
#include "net/curvecp/messenger.h"
#include "net/socket/stream_socket.h"

namespace net {

// A client socket that uses CurveCP as the transport layer.
class CurveCPClientSocket : public StreamSocket {
 public:
  // The IP address(es) and port number to connect to.  The CurveCP socket will
  // try each IP address in the list until it succeeds in establishing a
  // connection.
  CurveCPClientSocket(const AddressList& addresses,
                      net::NetLog* net_log,
                      const net::NetLog::Source& source);
  virtual ~CurveCPClientSocket();

  // ClientSocket methods:
  virtual int Connect(const CompletionCallback& callback) OVERRIDE;
  virtual void Disconnect() OVERRIDE;
  virtual bool IsConnected() const OVERRIDE;
  virtual bool IsConnectedAndIdle() const OVERRIDE;
  virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
  virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
  virtual const BoundNetLog& NetLog() const OVERRIDE;
  virtual void SetSubresourceSpeculation() OVERRIDE;
  virtual void SetOmniboxSpeculation() OVERRIDE;
  virtual bool WasEverUsed() const OVERRIDE;
  virtual bool UsingTCPFastOpen() const OVERRIDE;
  virtual int64 NumBytesRead() const OVERRIDE;
  virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE;
  virtual bool WasNpnNegotiated() const OVERRIDE;
  virtual NextProto GetNegotiatedProtocol() const OVERRIDE;
  virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;

  // Socket methods:
  virtual int Read(IOBuffer* buf,
                   int buf_len,
                   const CompletionCallback& callback) OVERRIDE;
  virtual int Write(IOBuffer* buf,
                    int buf_len,
                    const CompletionCallback& callback) OVERRIDE;
  virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
  virtual bool SetSendBufferSize(int32 size) OVERRIDE;

 private:
  AddressList addresses_;
  BoundNetLog net_log_;
  Messenger messenger_;
  ClientPacketizer packetizer_;

  DISALLOW_COPY_AND_ASSIGN(CurveCPClientSocket);
};

}  // namespace net

#endif  // NET_CURVECP_CURVECP_CLIENT_SOCKET_H_