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 COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_
6 #define COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_
10 #include "base/macros.h"
16 namespace copresence_sockets
{
18 // A CopresenceSocket is an object that is used to send receive data to and
19 // from CopresencePeers.
20 // TODO(rkc): Add the ability to connect to a remote CopresencePeer.
21 class CopresenceSocket
{
23 typedef base::Callback
<void(const scoped_refptr
<net::IOBuffer
>& buffer
,
24 int buffer_size
)> ReceiveCallback
;
27 virtual ~CopresenceSocket() {}
29 // Send data on this socket. If unable to send the data, return false. This
30 // operation only guarantees that if the return value is a success, the send
31 // was started. It does not make any guarantees about the completion of the
33 // TODO(rkc): Expand the bool into more a more detailed failures enum.
34 virtual bool Send(const scoped_refptr
<net::IOBuffer
>& buffer
,
36 virtual void Receive(const ReceiveCallback
& callback
) = 0;
39 DISALLOW_COPY_AND_ASSIGN(CopresenceSocket
);
42 } // namespace copresence_sockets
44 #endif // COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_