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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ 5 #ifndef MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
6 #define MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ 6 #define MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "mojo/common/handle_watcher.h"
9 #include "mojo/public/cpp/bindings/interface_impl.h" 11 #include "mojo/public/cpp/bindings/interface_impl.h"
10 #include "mojo/services/public/interfaces/network/tcp_connected_socket.mojom.h" 12 #include "mojo/services/public/interfaces/network/tcp_connected_socket.mojom.h"
11 #include "net/socket/tcp_socket.h" 13 #include "net/socket/tcp_socket.h"
mmenke 2014/10/17 16:49:56 Think we can just forward declare this.
12 14
13 namespace mojo { 15 namespace mojo {
14 16
17 class MojoToNetPendingBuffer;
18 class NetToMojoPendingBuffer;
19
15 class TCPConnectedSocketImpl : public InterfaceImpl<TCPConnectedSocket> { 20 class TCPConnectedSocketImpl : public InterfaceImpl<TCPConnectedSocket> {
16 public: 21 public:
17 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket, 22 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket,
18 ScopedDataPipeConsumerHandle send_stream, 23 ScopedDataPipeConsumerHandle send_stream,
19 ScopedDataPipeProducerHandle receive_stream); 24 ScopedDataPipeProducerHandle receive_stream);
20 virtual ~TCPConnectedSocketImpl(); 25 virtual ~TCPConnectedSocketImpl();
21 26
22 private: 27 private:
28 // "Receiving" in this context means reading from TCPSocket and writing to
29 // the Mojo receive_stream.
30 void ReceiveMore();
mmenke 2014/10/17 16:49:56 Really could use some more method-level docs.
31 void OnReceiveStreamReady(MojoResult result);
mmenke 2014/10/17 16:49:56 Include header for MojoResult?
32 void DidReceive(bool completed_synchronously, int result);
33
34 // "Writing" is reading from the Mojo send_stream and writing to the
35 // TCPSocket.
36 void SendMore();
37 void OnSendStreamReady(MojoResult result);
38 void DidSend(bool completed_asynchronously, int result);
39
23 scoped_ptr<net::TCPSocket> socket_; 40 scoped_ptr<net::TCPSocket> socket_;
41
42 // The *stream handles will be null while there is an in-progress transation
43 // between net and mojo. During this time, the handle will be owned by the
44 // *PendingBuffer.
45
46 // For reading from the network and writing to Mojo pipe.
24 ScopedDataPipeConsumerHandle send_stream_; 47 ScopedDataPipeConsumerHandle send_stream_;
48 common::HandleWatcher receive_handle_watcher_;
49 scoped_refptr<NetToMojoPendingBuffer> pending_receive_;
50
51 // For reading from the Mojo pipe and writing to the network.
25 ScopedDataPipeProducerHandle receive_stream_; 52 ScopedDataPipeProducerHandle receive_stream_;
53 common::HandleWatcher send_handle_watcher_;
54 scoped_refptr<MojoToNetPendingBuffer> pending_send_;
mmenke 2014/10/17 16:49:56 Need to include ref_counted.h.
55
56 base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_;
mmenke 2014/10/17 16:49:56 DISALLOW_COPY_AND_ASSIGN?
26 }; 57 };
27 58
28 } // namespace mojo 59 } // namespace mojo
29 60
30 #endif // MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ 61 #endif // MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698