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

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

Issue 2176443002: Add client and host dispatchers for video_stats channel to send video stats from host to client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_channel
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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHANNEL_DISPATCHER_BASE_H_ 5 #ifndef REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_
6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ 6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 22 matching lines...) Expand all
33 virtual ~EventHandler() {} 33 virtual ~EventHandler() {}
34 34
35 // Called after the channel is initialized. 35 // Called after the channel is initialized.
36 virtual void OnChannelInitialized( 36 virtual void OnChannelInitialized(
37 ChannelDispatcherBase* channel_dispatcher) = 0; 37 ChannelDispatcherBase* channel_dispatcher) = 0;
38 38
39 // Called after the channel is closed. 39 // Called after the channel is closed.
40 virtual void OnChannelClosed(ChannelDispatcherBase* channel_dispatcher) = 0; 40 virtual void OnChannelClosed(ChannelDispatcherBase* channel_dispatcher) = 0;
41 }; 41 };
42 42
43 // The callback is called when initialization is finished. The
44 // parameter is set to true on success.
45 typedef base::Callback<void(bool)> InitializedCallback;
46
47 ~ChannelDispatcherBase() override; 43 ~ChannelDispatcherBase() override;
48 44
49 // Creates and connects the channel using |channel_factory|. 45 // Creates and connects the channel using |channel_factory|.
50 void Init(MessageChannelFactory* channel_factory, 46 void Init(MessageChannelFactory* channel_factory,
51 EventHandler* event_handler); 47 EventHandler* event_handler);
52 48
53 // Initializes the channel using |message_pipe| that's already connected. 49 // Initializes the channel using |message_pipe| that's already connected.
54 void Init(std::unique_ptr<MessagePipe> message_pipe, 50 void Init(std::unique_ptr<MessagePipe> message_pipe,
55 EventHandler* event_handler); 51 EventHandler* event_handler);
56 52
57 const std::string& channel_name() { return channel_name_; } 53 const std::string& channel_name() { return channel_name_; }
58 54
59 // Returns true if the channel is currently connected. 55 // Returns true if the channel is currently connected.
60 bool is_connected() { return is_connected_; } 56 bool is_connected() { return is_connected_; }
61 57
62 protected: 58 protected:
63 explicit ChannelDispatcherBase(const char* channel_name); 59 explicit ChannelDispatcherBase(const std::string& channel_name);
64 60
65 MessagePipe* message_pipe() { return message_pipe_.get(); } 61 MessagePipe* message_pipe() { return message_pipe_.get(); }
66 62
67 // Child classes must override this method to handle incoming messages. 63 // Child classes must override this method to handle incoming messages.
68 virtual void OnIncomingMessage(std::unique_ptr<CompoundBuffer> message) = 0; 64 virtual void OnIncomingMessage(std::unique_ptr<CompoundBuffer> message) = 0;
69 65
70 private: 66 private:
71 void OnChannelReady(std::unique_ptr<MessagePipe> message_pipe); 67 void OnChannelReady(std::unique_ptr<MessagePipe> message_pipe);
72 68
73 // MessagePipe::EventHandler interface. 69 // MessagePipe::EventHandler interface.
74 void OnMessagePipeOpen() override; 70 void OnMessagePipeOpen() override;
75 void OnMessageReceived(std::unique_ptr<CompoundBuffer> message) override; 71 void OnMessageReceived(std::unique_ptr<CompoundBuffer> message) override;
76 void OnMessagePipeClosed() override; 72 void OnMessagePipeClosed() override;
77 73
78 std::string channel_name_; 74 std::string channel_name_;
79 MessageChannelFactory* channel_factory_ = nullptr; 75 MessageChannelFactory* channel_factory_ = nullptr;
80 EventHandler* event_handler_ = nullptr; 76 EventHandler* event_handler_ = nullptr;
81 bool is_connected_ = false; 77 bool is_connected_ = false;
82 78
83 std::unique_ptr<MessagePipe> message_pipe_; 79 std::unique_ptr<MessagePipe> message_pipe_;
84 80
85 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); 81 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase);
86 }; 82 };
87 83
88 } // namespace protocol 84 } // namespace protocol
89 } // namespace remoting 85 } // namespace remoting
90 86
91 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ 87 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698