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

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

Issue 1873463003: Remove mojo network service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
6 #define MOJO_SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "mojo/message_pump/handle_watcher.h"
11 #include "mojo/public/cpp/bindings/binding.h"
12 #include "mojo/services/network/public/interfaces/tcp_connected_socket.mojom.h"
13 #include "mojo/shell/public/cpp/message_loop_ref.h"
14 #include "net/socket/tcp_socket.h"
15
16 namespace mojo {
17
18 class MojoToNetPendingBuffer;
19 class NetToMojoPendingBuffer;
20
21 class TCPConnectedSocketImpl : public TCPConnectedSocket {
22 public:
23 TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket,
24 ScopedDataPipeConsumerHandle send_stream,
25 ScopedDataPipeProducerHandle receive_stream,
26 InterfaceRequest<TCPConnectedSocket> request,
27 scoped_ptr<mojo::MessageLoopRef> app_refcount);
28 ~TCPConnectedSocketImpl() override;
29
30 private:
31 void OnConnectionError();
32
33 // "Receiving" in this context means reading from TCPSocket and writing to
34 // the Mojo receive_stream.
35 void ReceiveMore();
36 void OnReceiveStreamReady(MojoResult result);
37 void DidReceive(bool completed_synchronously, int result);
38 void ShutdownReceive();
39 void ListenForReceivePeerClosed();
40 void OnReceiveDataPipeClosed(MojoResult result);
41
42 // "Writing" is reading from the Mojo send_stream and writing to the
43 // TCPSocket.
44 void SendMore();
45 void OnSendStreamReady(MojoResult result);
46 void DidSend(bool completed_asynchronously, int result);
47 void ShutdownSend();
48 void ListenForSendPeerClosed();
49 void OnSendDataPipeClosed(MojoResult result);
50
51 void DeleteIfNeeded();
52
53 scoped_ptr<net::TCPSocket> socket_;
54
55 // 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
57 // *PendingBuffer.
58
59 // For reading from the network and writing to Mojo pipe.
60 ScopedDataPipeConsumerHandle send_stream_;
61 scoped_refptr<NetToMojoPendingBuffer> pending_receive_;
62 common::HandleWatcher receive_handle_watcher_;
63
64 // For reading from the Mojo pipe and writing to the network.
65 ScopedDataPipeProducerHandle receive_stream_;
66 scoped_refptr<MojoToNetPendingBuffer> pending_send_;
67 common::HandleWatcher send_handle_watcher_;
68
69 // To bind to the message pipe.
70 Binding<TCPConnectedSocket> binding_;
71
72 scoped_ptr<mojo::MessageLoopRef> app_refcount_;
73
74 base::WeakPtrFactory<TCPConnectedSocketImpl> weak_ptr_factory_;
75 };
76
77 } // namespace mojo
78
79 #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