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

Unified Diff: mojo/services/network/tcp_connected_socket_impl.h

Issue 657113002: Add basic TCP socket mojo implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: mojo/services/network/tcp_connected_socket_impl.h
diff --git a/mojo/services/network/tcp_connected_socket_impl.h b/mojo/services/network/tcp_connected_socket_impl.h
index 5c24011344758a1deaba44762d8e163ce5c99ffd..e579b29251965b7e73dafaf0251ca455662ef908 100644
--- a/mojo/services/network/tcp_connected_socket_impl.h
+++ b/mojo/services/network/tcp_connected_socket_impl.h
@@ -6,12 +6,17 @@
#define MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "mojo/common/handle_watcher.h"
#include "mojo/public/cpp/bindings/interface_impl.h"
#include "mojo/services/public/interfaces/network/tcp_connected_socket.mojom.h"
#include "net/socket/tcp_socket.h"
mmenke 2014/10/17 16:49:56 Think we can just forward declare this.
namespace mojo {
+class MojoToNetPendingBuffer;
+class NetToMojoPendingBuffer;
+
class TCPConnectedSocketImpl : public InterfaceImpl<TCPConnectedSocket> {
public:
TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket,
@@ -20,9 +25,35 @@ class TCPConnectedSocketImpl : public InterfaceImpl<TCPConnectedSocket> {
virtual ~TCPConnectedSocketImpl();
private:
+ // "Receiving" in this context means reading from TCPSocket and writing to
+ // the Mojo receive_stream.
+ void ReceiveMore();
mmenke 2014/10/17 16:49:56 Really could use some more method-level docs.
+ void OnReceiveStreamReady(MojoResult result);
mmenke 2014/10/17 16:49:56 Include header for MojoResult?
+ void DidReceive(bool completed_synchronously, int result);
+
+ // "Writing" is reading from the Mojo send_stream and writing to the
+ // TCPSocket.
+ void SendMore();
+ void OnSendStreamReady(MojoResult result);
+ void DidSend(bool completed_asynchronously, int result);
+
scoped_ptr<net::TCPSocket> socket_;
+
+ // The *stream handles will be null while there is an in-progress transation
+ // between net and mojo. During this time, the handle will be owned by the
+ // *PendingBuffer.
+
+ // For reading from the network and writing to Mojo pipe.
ScopedDataPipeConsumerHandle send_stream_;
+ common::HandleWatcher receive_handle_watcher_;
+ scoped_refptr<NetToMojoPendingBuffer> pending_receive_;
+
+ // For reading from the Mojo pipe and writing to the network.
ScopedDataPipeProducerHandle receive_stream_;
+ common::HandleWatcher send_handle_watcher_;
+ scoped_refptr<MojoToNetPendingBuffer> pending_send_;
mmenke 2014/10/17 16:49:56 Need to include ref_counted.h.
+
+ base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_;
mmenke 2014/10/17 16:49:56 DISALLOW_COPY_AND_ASSIGN?
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698