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

Side by Side Diff: mojo/services/network/tcp_connected_socket_impl.h

Issue 1227373002: Roll mojo SDK to 734c6e1652ff2f3b696e441722838f453f4f9b42 (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Follow review Created 5 years, 5 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" 9 #include "base/memory/weak_ptr.h"
10 #include "mojo/common/handle_watcher.h" 10 #include "mojo/common/handle_watcher.h"
11 #include "mojo/services/network/public/interfaces/tcp_connected_socket.mojom.h" 11 #include "mojo/services/network/public/interfaces/tcp_connected_socket.mojom.h"
12 #include "net/socket/tcp_socket.h" 12 #include "net/socket/tcp_socket.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 16
17 class MojoToNetPendingBuffer; 17 class MojoToNetPendingBuffer;
18 class NetToMojoPendingBuffer; 18 class NetToMojoPendingBuffer;
19 19
20 class TCPConnectedSocketImpl : public TCPConnectedSocket, public ErrorHandler { 20 class TCPConnectedSocketImpl : public TCPConnectedSocket {
21 public: 21 public:
22 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket, 22 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket,
23 ScopedDataPipeConsumerHandle send_stream, 23 ScopedDataPipeConsumerHandle send_stream,
24 ScopedDataPipeProducerHandle receive_stream, 24 ScopedDataPipeProducerHandle receive_stream,
25 InterfaceRequest<TCPConnectedSocket> request); 25 InterfaceRequest<TCPConnectedSocket> request);
26 ~TCPConnectedSocketImpl() override; 26 ~TCPConnectedSocketImpl() override;
27 27
28 private: 28 private:
29 // ErrorHandler methods:
30 void OnConnectionError() override;
31
32 // "Receiving" in this context means reading from TCPSocket and writing to 29 // "Receiving" in this context means reading from TCPSocket and writing to
33 // the Mojo receive_stream. 30 // the Mojo receive_stream.
34 void ReceiveMore(); 31 void ReceiveMore();
35 void OnReceiveStreamReady(MojoResult result); 32 void OnReceiveStreamReady(MojoResult result);
36 void DidReceive(bool completed_synchronously, int result); 33 void DidReceive(bool completed_synchronously, int result);
37 void ShutdownReceive(); 34 void ShutdownReceive();
38 void ListenForReceivePeerClosed(); 35 void ListenForReceivePeerClosed();
39 void OnReceiveDataPipeClosed(MojoResult result); 36 void OnReceiveDataPipeClosed(MojoResult result);
40 37
41 // "Writing" is reading from the Mojo send_stream and writing to the 38 // "Writing" is reading from the Mojo send_stream and writing to the
42 // TCPSocket. 39 // TCPSocket.
43 void SendMore(); 40 void SendMore();
44 void SendMoreAsync(); 41 void SendMoreAsync();
45 void OnSendStreamReady(MojoResult result); 42 void OnSendStreamReady(MojoResult result);
46 void DidSend(bool completed_asynchronously, int result); 43 void DidSend(bool completed_asynchronously, int result);
47 void ShutdownSend(); 44 void ShutdownSend();
48 void ListenForSendPeerClosed(); 45 void ListenForSendPeerClosed();
49 void OnSendDataPipeClosed(MojoResult result); 46 void OnSendDataPipeClosed(MojoResult result);
50 47
48 void OnConnectionError();
51 void DeleteIfNeeded(); 49 void DeleteIfNeeded();
52 50
53 scoped_ptr<net::TCPSocket> socket_; 51 scoped_ptr<net::TCPSocket> socket_;
54 52
55 // The *stream handles will be null while there is an in-progress transation 53 // The *stream handles will be null while there is an in-progress transation
56 // between net and mojo. During this time, the handle will be owned by the 54 // between net and mojo. During this time, the handle will be owned by the
57 // *PendingBuffer. 55 // *PendingBuffer.
58 56
59 // For reading from the network and writing to Mojo pipe. 57 // For reading from the network and writing to Mojo pipe.
60 ScopedDataPipeConsumerHandle send_stream_; 58 ScopedDataPipeConsumerHandle send_stream_;
61 scoped_refptr<NetToMojoPendingBuffer> pending_receive_; 59 scoped_refptr<NetToMojoPendingBuffer> pending_receive_;
62 common::HandleWatcher receive_handle_watcher_; 60 common::HandleWatcher receive_handle_watcher_;
63 61
64 // For reading from the Mojo pipe and writing to the network. 62 // For reading from the Mojo pipe and writing to the network.
65 ScopedDataPipeProducerHandle receive_stream_; 63 ScopedDataPipeProducerHandle receive_stream_;
66 scoped_refptr<MojoToNetPendingBuffer> pending_send_; 64 scoped_refptr<MojoToNetPendingBuffer> pending_send_;
67 common::HandleWatcher send_handle_watcher_; 65 common::HandleWatcher send_handle_watcher_;
68 66
69 // To bind to the message pipe. 67 // To bind to the message pipe.
70 Binding<TCPConnectedSocket> binding_; 68 Binding<TCPConnectedSocket> binding_;
71 69
72 bool send_more_posted_; 70 bool send_more_posted_;
73 71
74 base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_; 72 base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_;
75 }; 73 };
76 74
77 } // namespace mojo 75 } // namespace mojo
78 76
79 #endif // MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ 77 #endif // MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
OLDNEW
« no previous file with comments | « mojo/services/network/tcp_bound_socket_impl.cc ('k') | mojo/services/network/tcp_connected_socket_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698