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

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 "remoting/protocol/message_pipe.h"
9
10 #include "base/callback.h"
11 #include "remoting/base/buffered_socket_writer.h"
12 #include "remoting/protocol/message_reader.h"
13
14 namespace remoting {
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();
26 ~StreamMessagePipeAdapter() override;
27
28 // Starts reading from |socket|.
29 void Initialize(scoped_ptr<P2PStreamSocket> socket,
30 const ErrorCallback& error_callback);
31
32 // MessagePipe interface.
33 void StartReceiving(const MessageReceivedCallback& callback) override;
34 void Send(google::protobuf::MessageLite* message,
35 const base::Closure& done) override;
36
37 private:
38 void CloseOnError(int error);
39
40 scoped_ptr<P2PStreamSocket> socket_;
41 ErrorCallback error_callback_;
42
43 bool closed_ = false;
44
45 MessageReader reader_;
46 BufferedSocketWriter writer_;
47
48 DISALLOW_COPY_AND_ASSIGN(StreamMessagePipeAdapter);
49 };
50
51 } // namespace protocol
52 } // namespace remoting
53
54 #endif // REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698