OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_PACKETIZER_H_ | 5 #ifndef NET_CURVECP_PACKETIZER_H_ |
6 #define NET_CURVECP_PACKETIZER_H_ | 6 #define NET_CURVECP_PACKETIZER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
11 #include "net/curvecp/connection_key.h" | 11 #include "net/curvecp/connection_key.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 class IPEndPoint; | 15 class IPEndPoint; |
16 | 16 |
17 class Packetizer { | 17 class Packetizer { |
18 public: | 18 public: |
19 class Listener { | 19 class Listener { |
20 public: | 20 public: |
21 virtual ~Listener() {} | 21 virtual ~Listener() {} |
22 // Callback for new connections. | 22 // Callback for new connections. |
23 virtual void OnConnection(ConnectionKey key) = 0; | 23 virtual void OnConnection(ConnectionKey key) = 0; |
24 virtual void OnMessage(Packetizer* packetizer, | 24 virtual void OnMessage(Packetizer* packetizer, |
25 ConnectionKey key, | 25 ConnectionKey key, |
26 unsigned char* msg, | 26 unsigned char* msg, |
27 size_t length) = 0; | 27 size_t length) = 0; |
28 }; | 28 }; |
29 | 29 |
30 virtual ~Packetizer() {} | |
31 | |
32 // Send a message on a connection. | 30 // Send a message on a connection. |
33 virtual int SendMessage(ConnectionKey key, | 31 virtual int SendMessage(ConnectionKey key, |
34 const char* data, | 32 const char* data, |
35 size_t length, | 33 size_t length, |
36 const CompletionCallback& callback) = 0; | 34 const CompletionCallback& callback) = 0; |
37 | 35 |
38 // Close an existing connection. | 36 // Close an existing connection. |
39 virtual void Close(ConnectionKey key) = 0; | 37 virtual void Close(ConnectionKey key) = 0; |
40 | 38 |
41 virtual int GetPeerAddress(IPEndPoint* addresses) const = 0; | 39 virtual int GetPeerAddress(IPEndPoint* addresses) const = 0; |
42 | 40 |
43 // Returns the current maximum message size which can be fit into the next | 41 // Returns the current maximum message size which can be fit into the next |
44 // message payload to be sent on the packetizer. | 42 // message payload to be sent on the packetizer. |
45 virtual int max_message_payload() const = 0; | 43 virtual int max_message_payload() const = 0; |
| 44 |
| 45 protected: |
| 46 virtual ~Packetizer() {} |
46 }; | 47 }; |
47 | 48 |
48 } // namespace net | 49 } // namespace net |
49 | 50 |
50 #endif // NET_CURVECP_PACKETIZER_H_ | 51 #endif // NET_CURVECP_PACKETIZER_H_ |
OLD | NEW |