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

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

Issue 2146213002: Add support for dynamic channels in WebrtcTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « remoting/protocol/ice_connection_to_host.cc ('k') | remoting/protocol/message_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MESSAGE_PIPE_H_ 5 #ifndef REMOTING_PROTOCOL_MESSAGE_PIPE_H_
6 #define REMOTING_PROTOCOL_MESSAGE_PIPE_H_ 6 #define REMOTING_PROTOCOL_MESSAGE_PIPE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 11
12 namespace google { 12 namespace google {
13 namespace protobuf { 13 namespace protobuf {
14 class MessageLite; 14 class MessageLite;
15 } // namespace protobuf 15 } // namespace protobuf
16 } // namespace google 16 } // namespace google
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 class CompoundBuffer; 20 class CompoundBuffer;
21 21
22 namespace protocol { 22 namespace protocol {
23 23
24 // Represents a bi-directional pipe that allows to send and receive messages. 24 // Represents a bi-directional pipe that allows to send and receive messages.
25 class MessagePipe { 25 class MessagePipe {
26 public: 26 public:
27 typedef base::Callback<void(std::unique_ptr<CompoundBuffer> message)> 27 class EventHandler {
28 MessageReceivedCallback; 28 public:
29 // Called when a message is received.
30 virtual void OnMessageReceived(std::unique_ptr<CompoundBuffer> message) = 0;
31
32 // Called when the channel is closed.
33 virtual void OnMessagePipeClosed() = 0;
34
35 protected:
36 virtual ~EventHandler() {}
37 };
29 38
30 virtual ~MessagePipe() {} 39 virtual ~MessagePipe() {}
31 40
32 // Starts receiving incoming messages and calls |callback| for each message. 41 // Starts the channel. |event_handler| will be called to notify when a message
33 virtual void StartReceiving(const MessageReceivedCallback& callback) = 0; 42 // is received or the pipe is closed.
43 virtual void Start(EventHandler* event_handler) = 0;
34 44
35 // Sends a message. |done| is called when the message has been sent to the 45 // Sends a message. |done| is called when the message has been sent to the
36 // client, but it doesn't mean that the client has received it. |done| is 46 // client, but it doesn't mean that the client has received it. |done| is
37 // never called if the message is never sent (e.g. if the pipe is destroyed 47 // never called if the message is never sent (e.g. if the pipe is destroyed
38 // before the message is sent). 48 // before the message is sent).
39 virtual void Send(google::protobuf::MessageLite* message, 49 virtual void Send(google::protobuf::MessageLite* message,
40 const base::Closure& done) = 0; 50 const base::Closure& done) = 0;
41 }; 51 };
42 52
43 } // namespace protocol 53 } // namespace protocol
44 } // namespace remoting 54 } // namespace remoting
45 55
46 #endif // REMOTING_PROTOCOL_MESSAGE_PIPE_H_ 56 #endif // REMOTING_PROTOCOL_MESSAGE_PIPE_H_
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_host.cc ('k') | remoting/protocol/message_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698