Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: components/copresence_sockets/public/copresence_socket.h

Issue 610633002: Prototype for copresenceSockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698