summaryrefslogtreecommitdiffstats
path: root/net/curvecp/packetizer.h
blob: 14b526a1ed7a063bc0d6306ace60a8050208dc9b (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
// Copyright (c) 2011 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_PACKETIZER_H_
#define NET_CURVECP_PACKETIZER_H_
#pragma once

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "net/base/completion_callback.h"
#include "net/curvecp/connection_key.h"

namespace net {

class IPEndPoint;

class Packetizer {
 public:
  class Listener {
   public:
    virtual ~Listener() {}
    // Callback for new connections.
    virtual void OnConnection(ConnectionKey key) = 0;
    virtual void OnMessage(Packetizer* packetizer,
                           ConnectionKey key,
                           unsigned char* msg,
                           size_t length)  = 0;
  };

  virtual ~Packetizer() {}

  // Send a message on a connection.
  virtual int SendMessage(ConnectionKey key,
                          const char* data,
                          size_t length,
                          OldCompletionCallback* callback) = 0;

  // Close an existing connection.
  virtual void Close(ConnectionKey key) = 0;

  virtual int GetPeerAddress(IPEndPoint* addresses) const = 0;

  // Returns the current maximum message size which can be fit into the next
  // message payload to be sent on the packetizer.
  virtual int max_message_payload() const = 0;
};

}  // namespace net

#endif  // NET_CURVECP_PACKETIZER_H_