Roll src/third_party/WebKit bf18a82:a9cee16 (svn 185297:185304)
[chromium-blink-merge.git] / components / copresence_sockets / public / copresence_socket.h
blobc97073265c58d0a3daf9da7dc703f03f9a699f3d
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_
8 #include <string>
10 #include "base/macros.h"
12 namespace net {
13 class IOBuffer;
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 {
22 public:
23 typedef base::Callback<void(const scoped_refptr<net::IOBuffer>& buffer,
24 int buffer_size)> ReceiveCallback;
26 CopresenceSocket() {}
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
32 // operation.
33 // TODO(rkc): Expand the bool into more a more detailed failures enum.
34 virtual bool Send(const scoped_refptr<net::IOBuffer>& buffer,
35 int buffer_size) = 0;
36 virtual void Receive(const ReceiveCallback& callback) = 0;
38 private:
39 DISALLOW_COPY_AND_ASSIGN(CopresenceSocket);
42 } // namespace copresence_sockets
44 #endif // COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_