OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ |
| 6 #define REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "remoting/protocol/message_pipe.h" |
| 10 #include "remoting/protocol/message_reader.h" |
| 11 |
| 12 namespace remoting { |
| 13 class BufferedSocketWriter; |
| 14 |
| 15 namespace protocol { |
| 16 |
| 17 class P2PStreamSocket; |
| 18 |
| 19 // MessagePipe implementation that sends and receives messages over a |
| 20 // P2PStreamChannel. |
| 21 class StreamMessagePipeAdapter : public MessagePipe { |
| 22 public: |
| 23 typedef base::Callback<void(int)> ErrorCallback; |
| 24 |
| 25 StreamMessagePipeAdapter(scoped_ptr<P2PStreamSocket> socket, |
| 26 const ErrorCallback& error_callback); |
| 27 ~StreamMessagePipeAdapter() override; |
| 28 |
| 29 // MessagePipe interface. |
| 30 void StartReceiving(const MessageReceivedCallback& callback) override; |
| 31 void Send(google::protobuf::MessageLite* message, |
| 32 const base::Closure& done) override; |
| 33 |
| 34 private: |
| 35 void CloseOnError(int error); |
| 36 |
| 37 scoped_ptr<P2PStreamSocket> socket_; |
| 38 ErrorCallback error_callback_; |
| 39 |
| 40 MessageReader reader_; |
| 41 scoped_ptr<BufferedSocketWriter> writer_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(StreamMessagePipeAdapter); |
| 44 }; |
| 45 |
| 46 } // namespace protocol |
| 47 } // namespace remoting |
| 48 |
| 49 #endif // REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ |
OLD | NEW |