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 copresence_sockets { | |
13 | |
14 // A CopresenceSocket is an object that is used to send receive data. Currently | |
15 // this object is only created by a CopresencePeer once it receives a | |
16 // 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.
| |
17 // TODO(rkc): Add the ability to connect to a remote CopresencePeer. | |
18 class CopresenceSocket { | |
19 public: | |
20 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.
| |
21 | |
22 CopresenceSocket() {} | |
23 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
| |
24 | |
25 // Attempt to send data on this socket. If we were unable to send the data, | |
26 // 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.
| |
27 // TODO(rkc): Expand the bool into more a more detailed failures enum. | |
28 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
| |
29 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.
| |
30 | |
31 private: | |
32 DISALLOW_COPY_AND_ASSIGN(CopresenceSocket); | |
33 }; | |
34 | |
35 } // namespace copresence_sockets | |
36 | |
37 #endif // COMPONENTS_COPRESENCE_SOCKETS_COPRESENCE_SOCKET_H_ | |
OLD | NEW |