OLD | NEW |
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" | 9 #include "base/memory/weak_ptr.h" |
10 #include "mojo/message_pump/handle_watcher.h" | 10 #include "mojo/message_pump/handle_watcher.h" |
11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
12 #include "mojo/services/network/public/interfaces/tcp_connected_socket.mojom.h" | 12 #include "mojo/services/network/public/interfaces/tcp_connected_socket.mojom.h" |
13 #include "mojo/shell/public/cpp/shell.h" | 13 #include "mojo/shell/public/cpp/message_loop_ref.h" |
14 #include "net/socket/tcp_socket.h" | 14 #include "net/socket/tcp_socket.h" |
15 | 15 |
16 namespace mojo { | 16 namespace mojo { |
17 | 17 |
18 class MojoToNetPendingBuffer; | 18 class MojoToNetPendingBuffer; |
19 class NetToMojoPendingBuffer; | 19 class NetToMojoPendingBuffer; |
20 | 20 |
21 class TCPConnectedSocketImpl : public TCPConnectedSocket { | 21 class TCPConnectedSocketImpl : public TCPConnectedSocket { |
22 public: | 22 public: |
23 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket, | 23 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket, |
24 ScopedDataPipeConsumerHandle send_stream, | 24 ScopedDataPipeConsumerHandle send_stream, |
25 ScopedDataPipeProducerHandle receive_stream, | 25 ScopedDataPipeProducerHandle receive_stream, |
26 InterfaceRequest<TCPConnectedSocket> request, | 26 InterfaceRequest<TCPConnectedSocket> request, |
27 scoped_ptr<mojo::AppRefCount> app_refcount); | 27 scoped_ptr<mojo::MessageLoopRef> app_refcount); |
28 ~TCPConnectedSocketImpl() override; | 28 ~TCPConnectedSocketImpl() override; |
29 | 29 |
30 private: | 30 private: |
31 void OnConnectionError(); | 31 void OnConnectionError(); |
32 | 32 |
33 // "Receiving" in this context means reading from TCPSocket and writing to | 33 // "Receiving" in this context means reading from TCPSocket and writing to |
34 // the Mojo receive_stream. | 34 // the Mojo receive_stream. |
35 void ReceiveMore(); | 35 void ReceiveMore(); |
36 void OnReceiveStreamReady(MojoResult result); | 36 void OnReceiveStreamReady(MojoResult result); |
37 void DidReceive(bool completed_synchronously, int result); | 37 void DidReceive(bool completed_synchronously, int result); |
(...skipping 24 matching lines...) Expand all Loading... |
62 common::HandleWatcher receive_handle_watcher_; | 62 common::HandleWatcher receive_handle_watcher_; |
63 | 63 |
64 // For reading from the Mojo pipe and writing to the network. | 64 // For reading from the Mojo pipe and writing to the network. |
65 ScopedDataPipeProducerHandle receive_stream_; | 65 ScopedDataPipeProducerHandle receive_stream_; |
66 scoped_refptr<MojoToNetPendingBuffer> pending_send_; | 66 scoped_refptr<MojoToNetPendingBuffer> pending_send_; |
67 common::HandleWatcher send_handle_watcher_; | 67 common::HandleWatcher send_handle_watcher_; |
68 | 68 |
69 // To bind to the message pipe. | 69 // To bind to the message pipe. |
70 Binding<TCPConnectedSocket> binding_; | 70 Binding<TCPConnectedSocket> binding_; |
71 | 71 |
72 scoped_ptr<mojo::AppRefCount> app_refcount_; | 72 scoped_ptr<mojo::MessageLoopRef> app_refcount_; |
73 | 73 |
74 base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_; | 74 base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_; |
75 }; | 75 }; |
76 | 76 |
77 } // namespace mojo | 77 } // namespace mojo |
78 | 78 |
79 #endif // MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ | 79 #endif // MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ |
OLD | NEW |