Chromium Code Reviews| Index: components/copresence_sockets/public/copresence_socket.h |
| diff --git a/components/copresence_sockets/public/copresence_socket.h b/components/copresence_sockets/public/copresence_socket.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9de6ddb36d419ec9abb1b494fe0aa26c875c1825 |
| --- /dev/null |
| +++ b/components/copresence_sockets/public/copresence_socket.h |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2014 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 COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ |
| +#define COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| + |
| +namespace copresence_sockets { |
| + |
| +// A CopresenceSocket is an object that is used to send receive data. Currently |
| +// this object is only created by a CopresencePeer once it receives a |
| +// connection request. This class is currently just a pure interface. |
|
Ryan Sleevi
2014/10/01 19:47:25
LAYERING: Document how to use this class, not how
rkc
2014/10/01 22:38:48
Changed.
Done.
|
| +// TODO(rkc): Add the ability to connect to a remote CopresencePeer. |
| +class CopresenceSocket { |
| + public: |
| + typedef base::Callback<void(const std::string&)> ReceiveCallback; |
|
Ryan Sleevi
2014/10/01 19:47:25
DESIGN: std::string vs base::StringPiece
rkc
2014/10/01 22:38:48
Changed to using net::IOBuffer instead.
|
| + |
| + CopresenceSocket() {} |
| + virtual ~CopresenceSocket() {} |
|
Ryan Sleevi
2014/10/01 19:47:24
DESIGN: Is a public destructor correct for this cl
rkc
2014/10/01 22:38:48
So CopresenceSockets will be owned by classes othe
|
| + |
| + // Attempt to send data on this socket. If we were unable to send the data, |
| + // the method returns false. |
|
Ryan Sleevi
2014/10/01 19:47:24
STYLE: Pronouns in comments considered harmful - h
rkc
2014/10/01 22:38:48
Done.
|
| + // TODO(rkc): Expand the bool into more a more detailed failures enum. |
| + virtual bool Send(const std::string& data) = 0; |
|
Ryan Sleevi
2014/10/01 19:47:24
DESIGN: Synchronous methods for sockets are ALWAYS
Ryan Sleevi
2014/10/01 19:47:25
DESIGN: Don't use std::string for buffers of data.
rkc
2014/10/01 22:38:48
Done.
rkc
2014/10/01 22:38:48
We are designing this API so that Send only means
|
| + virtual void Receive(ReceiveCallback callback) = 0; |
|
Ryan Sleevi
2014/10/01 19:47:24
STYLE: Pass as const-ref.
Ryan Sleevi
2014/10/01 19:47:25
DESIGN: Let the caller specify how much data they'
rkc
2014/10/01 22:38:48
Done.
rkc
2014/10/01 22:38:48
Done.
|
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(CopresenceSocket); |
| +}; |
| + |
| +} // namespace copresence_sockets |
| + |
| +#endif // COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ |