OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ |
| 6 #define COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 |
| 12 namespace net { |
| 13 class IOBuffer; |
| 14 } |
| 15 |
| 16 namespace copresence_sockets { |
| 17 |
| 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; |
| 25 |
| 26 CopresenceSocket() {} |
| 27 virtual ~CopresenceSocket() {} |
| 28 |
| 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; |
| 37 |
| 38 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(CopresenceSocket); |
| 40 }; |
| 41 |
| 42 } // namespace copresence_sockets |
| 43 |
| 44 #endif // COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ |
OLD | NEW |