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

Side by Side Diff: remoting/protocol/stream_message_pipe_adapter.h

Issue 1649063003: Add MessagePipe interface. Use it in ChannelDispatcherBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_parser
Patch Set: Created 4 years, 10 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 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698