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

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

Issue 2164163002: Simplify data channel creation logic in WebRTC-based protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits 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
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 class EventHandler { 27 class EventHandler {
28 public: 28 public:
29 // Called when the channel is open.
30 virtual void OnMessagePipeOpen() = 0;
31
29 // Called when a message is received. 32 // Called when a message is received.
30 virtual void OnMessageReceived(std::unique_ptr<CompoundBuffer> message) = 0; 33 virtual void OnMessageReceived(std::unique_ptr<CompoundBuffer> message) = 0;
31 34
32 // Called when the channel is closed. 35 // Called when the channel is closed.
33 virtual void OnMessagePipeClosed() = 0; 36 virtual void OnMessagePipeClosed() = 0;
34 37
35 protected: 38 protected:
36 virtual ~EventHandler() {} 39 virtual ~EventHandler() {}
37 }; 40 };
38 41
39 virtual ~MessagePipe() {} 42 virtual ~MessagePipe() {}
40 43
41 // Starts the channel. |event_handler| will be called to notify when a message 44 // Starts the channel. Must be called immediately after MessagePipe is
42 // is received or the pipe is closed. 45 // created. |event_handler| will be notified when state of the pipe changes or
46 // when a message is received.
43 virtual void Start(EventHandler* event_handler) = 0; 47 virtual void Start(EventHandler* event_handler) = 0;
44 48
45 // Sends a message. |done| is called when the message has been sent to the 49 // Sends a message. |done| is called when the message has been sent to the
46 // client, but it doesn't mean that the client has received it. |done| is 50 // client, but it doesn't mean that the client has received it. |done| is
47 // never called if the message is never sent (e.g. if the pipe is destroyed 51 // never called if the message is never sent (e.g. if the pipe is destroyed
48 // before the message is sent). 52 // before the message is sent).
49 virtual void Send(google::protobuf::MessageLite* message, 53 virtual void Send(google::protobuf::MessageLite* message,
50 const base::Closure& done) = 0; 54 const base::Closure& done) = 0;
51 }; 55 };
52 56
53 } // namespace protocol 57 } // namespace protocol
54 } // namespace remoting 58 } // namespace remoting
55 59
56 #endif // REMOTING_PROTOCOL_MESSAGE_PIPE_H_ 60 #endif // REMOTING_PROTOCOL_MESSAGE_PIPE_H_
OLDNEW
« no previous file with comments | « remoting/protocol/connection_tester.cc ('k') | remoting/protocol/stream_message_pipe_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698