1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_P2P_SOCKET_CLIENT_DELEGATE_H_
6 #define CONTENT_RENDERER_P2P_SOCKET_CLIENT_DELEGATE_H_
10 #include "base/memory/ref_counted.h"
11 #include "content/common/p2p_socket_type.h"
12 #include "net/base/ip_endpoint.h"
16 class P2PSocketClient
;
18 class P2PSocketClientDelegate
{
20 virtual ~P2PSocketClientDelegate() { }
22 // Called after the socket has been opened with the local endpoint address
23 // as argument. Please note that in the precence of multiple interfaces,
24 // you should not rely on the local endpoint address if possible.
25 virtual void OnOpen(const net::IPEndPoint
& local_address
,
26 const net::IPEndPoint
& remote_address
) = 0;
28 // For a socket that is listening on incoming TCP connectsion, this
29 // function is called when a new client connects.
30 virtual void OnIncomingTcpConnection(const net::IPEndPoint
& address
,
31 P2PSocketClient
* client
) = 0;
33 // Called once for each Send() call after the send is complete.
34 virtual void OnSendComplete(const P2PSendPacketMetrics
& send_metrics
) = 0;
36 // Called if an non-retryable error occurs.
37 virtual void OnError() = 0;
39 // Called when data is received on the socket.
40 virtual void OnDataReceived(const net::IPEndPoint
& address
,
41 const std::vector
<char>& data
,
42 const base::TimeTicks
& timestamp
) = 0;
45 } // namespace content
47 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_DELEGATE_H_