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 #ifndef NET_CURVECP_CURVECP_CLIENT_SOCKET_H_ | 5 #ifndef NET_CURVECP_CURVECP_CLIENT_SOCKET_H_ |
6 #define NET_CURVECP_CURVECP_CLIENT_SOCKET_H_ | 6 #define NET_CURVECP_CURVECP_CLIENT_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
11 #include "net/curvecp/client_packetizer.h" | 11 #include "net/curvecp/client_packetizer.h" |
12 #include "net/curvecp/messenger.h" | 12 #include "net/curvecp/messenger.h" |
13 #include "net/socket/stream_socket.h" | 13 #include "net/socket/stream_socket.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 // A client socket that uses CurveCP as the transport layer. | 17 // A client socket that uses CurveCP as the transport layer. |
18 class CurveCPClientSocket : public StreamSocket { | 18 class CurveCPClientSocket : public StreamSocket { |
19 public: | 19 public: |
20 // The IP address(es) and port number to connect to. The CurveCP socket will | 20 // The IP address(es) and port number to connect to. The CurveCP socket will |
21 // try each IP address in the list until it succeeds in establishing a | 21 // try each IP address in the list until it succeeds in establishing a |
22 // connection. | 22 // connection. |
23 CurveCPClientSocket(const AddressList& addresses, | 23 CurveCPClientSocket(const AddressList& addresses, |
24 net::NetLog* net_log, | 24 net::NetLog* net_log, |
25 const net::NetLog::Source& source); | 25 const net::NetLog::Source& source); |
26 virtual ~CurveCPClientSocket(); | 26 virtual ~CurveCPClientSocket(); |
27 | 27 |
28 // ClientSocket implementation. | 28 // ClientSocket methods: |
29 virtual int Connect(OldCompletionCallback* callback) OVERRIDE; | 29 virtual int Connect(const CompletionCallback& callback) OVERRIDE; |
30 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; | |
31 virtual void Disconnect() OVERRIDE; | 30 virtual void Disconnect() OVERRIDE; |
32 virtual bool IsConnected() const OVERRIDE; | 31 virtual bool IsConnected() const OVERRIDE; |
33 virtual bool IsConnectedAndIdle() const OVERRIDE; | 32 virtual bool IsConnectedAndIdle() const OVERRIDE; |
34 virtual int GetPeerAddress(AddressList* address) const OVERRIDE; | 33 virtual int GetPeerAddress(AddressList* address) const OVERRIDE; |
35 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | 34 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; |
36 virtual const BoundNetLog& NetLog() const OVERRIDE; | 35 virtual const BoundNetLog& NetLog() const OVERRIDE; |
37 virtual void SetSubresourceSpeculation() OVERRIDE; | 36 virtual void SetSubresourceSpeculation() OVERRIDE; |
38 virtual void SetOmniboxSpeculation() OVERRIDE; | 37 virtual void SetOmniboxSpeculation() OVERRIDE; |
39 virtual bool WasEverUsed() const OVERRIDE; | 38 virtual bool WasEverUsed() const OVERRIDE; |
40 virtual bool UsingTCPFastOpen() const OVERRIDE; | 39 virtual bool UsingTCPFastOpen() const OVERRIDE; |
41 virtual int64 NumBytesRead() const OVERRIDE; | 40 virtual int64 NumBytesRead() const OVERRIDE; |
42 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; | 41 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; |
43 | 42 |
44 // Socket implementation. | 43 // Socket methods: |
45 virtual int Read(IOBuffer* buf, | |
46 int buf_len, | |
47 OldCompletionCallback* callback) OVERRIDE; | |
48 virtual int Read(IOBuffer* buf, | 44 virtual int Read(IOBuffer* buf, |
49 int buf_len, | 45 int buf_len, |
50 const CompletionCallback& callback) OVERRIDE; | 46 const CompletionCallback& callback) OVERRIDE; |
51 virtual int Write(IOBuffer* buf, | 47 virtual int Write(IOBuffer* buf, |
52 int buf_len, | 48 int buf_len, |
53 OldCompletionCallback* callback) OVERRIDE; | 49 const CompletionCallback& callback) OVERRIDE; |
54 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; | 50 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
55 virtual bool SetSendBufferSize(int32 size) OVERRIDE; | 51 virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
56 | 52 |
57 private: | 53 private: |
58 AddressList addresses_; | 54 AddressList addresses_; |
59 BoundNetLog net_log_; | 55 BoundNetLog net_log_; |
60 Messenger messenger_; | 56 Messenger messenger_; |
61 ClientPacketizer packetizer_; | 57 ClientPacketizer packetizer_; |
62 | 58 |
63 DISALLOW_COPY_AND_ASSIGN(CurveCPClientSocket); | 59 DISALLOW_COPY_AND_ASSIGN(CurveCPClientSocket); |
64 }; | 60 }; |
65 | 61 |
66 } // namespace net | 62 } // namespace net |
67 | 63 |
68 #endif // NET_CURVECP_CURVECP_CLIENT_SOCKET_H_ | 64 #endif // NET_CURVECP_CURVECP_CLIENT_SOCKET_H_ |
OLD | NEW |