OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ | 5 #ifndef REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ |
6 #define REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ | 6 #define REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "remoting/protocol/message_channel_factory.h" | 9 #include "remoting/protocol/message_channel_factory.h" |
10 #include "remoting/protocol/message_pipe.h" | 10 #include "remoting/protocol/message_pipe.h" |
11 #include "remoting/protocol/message_reader.h" | 11 #include "remoting/protocol/message_reader.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 class BufferedSocketWriter; | 14 class BufferedSocketWriter; |
15 | 15 |
16 namespace protocol { | 16 namespace protocol { |
17 | 17 |
18 class P2PStreamSocket; | 18 class P2PStreamSocket; |
19 class StreamChannelFactory; | 19 class StreamChannelFactory; |
20 | 20 |
21 // MessagePipe implementation that sends and receives messages over a | 21 // MessagePipe implementation that sends and receives messages over a |
22 // P2PStreamChannel. | 22 // P2PStreamSocket. |
23 class StreamMessagePipeAdapter : public MessagePipe { | 23 class StreamMessagePipeAdapter : public MessagePipe { |
24 public: | 24 public: |
25 typedef base::Callback<void(int)> ErrorCallback; | 25 typedef base::Callback<void(int)> ErrorCallback; |
26 | 26 |
27 StreamMessagePipeAdapter(std::unique_ptr<P2PStreamSocket> socket, | 27 StreamMessagePipeAdapter(std::unique_ptr<P2PStreamSocket> socket, |
28 const ErrorCallback& error_callback); | 28 const ErrorCallback& error_callback); |
29 ~StreamMessagePipeAdapter() override; | 29 ~StreamMessagePipeAdapter() override; |
30 | 30 |
31 // MessagePipe interface. | 31 // MessagePipe interface. |
32 void Start(EventHandler* event_handler) override; | 32 void Start(EventHandler* event_handler) override; |
33 void Send(google::protobuf::MessageLite* message, | 33 void Send(google::protobuf::MessageLite* message, |
34 const base::Closure& done) override; | 34 const base::Closure& done) override; |
35 | 35 |
36 private: | 36 private: |
37 void CloseOnError(int error); | 37 void CloseOnError(int error); |
38 | 38 |
| 39 EventHandler* event_handler_ = nullptr; |
| 40 |
39 std::unique_ptr<P2PStreamSocket> socket_; | 41 std::unique_ptr<P2PStreamSocket> socket_; |
40 ErrorCallback error_callback_; | 42 ErrorCallback error_callback_; |
41 | 43 |
42 MessageReader reader_; | 44 std::unique_ptr<MessageReader> reader_; |
43 std::unique_ptr<BufferedSocketWriter> writer_; | 45 std::unique_ptr<BufferedSocketWriter> writer_; |
44 | 46 |
45 DISALLOW_COPY_AND_ASSIGN(StreamMessagePipeAdapter); | 47 DISALLOW_COPY_AND_ASSIGN(StreamMessagePipeAdapter); |
46 }; | 48 }; |
47 | 49 |
48 class StreamMessageChannelFactoryAdapter : public MessageChannelFactory { | 50 class StreamMessageChannelFactoryAdapter : public MessageChannelFactory { |
49 public: | 51 public: |
50 typedef base::Callback<void(int)> ErrorCallback; | 52 typedef base::Callback<void(int)> ErrorCallback; |
51 | 53 |
52 StreamMessageChannelFactoryAdapter( | 54 StreamMessageChannelFactoryAdapter( |
(...skipping 13 matching lines...) Expand all Loading... |
66 StreamChannelFactory* stream_channel_factory_; | 68 StreamChannelFactory* stream_channel_factory_; |
67 ErrorCallback error_callback_; | 69 ErrorCallback error_callback_; |
68 | 70 |
69 DISALLOW_COPY_AND_ASSIGN(StreamMessageChannelFactoryAdapter); | 71 DISALLOW_COPY_AND_ASSIGN(StreamMessageChannelFactoryAdapter); |
70 }; | 72 }; |
71 | 73 |
72 } // namespace protocol | 74 } // namespace protocol |
73 } // namespace remoting | 75 } // namespace remoting |
74 | 76 |
75 #endif // REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ | 77 #endif // REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ |
OLD | NEW |