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

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

Issue 1654513003: Simplify message parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_done
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
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 <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 const std::string& channel_name() { return channel_name_; } 49 const std::string& channel_name() { return channel_name_; }
50 50
51 // Returns true if the channel is currently connected. 51 // Returns true if the channel is currently connected.
52 bool is_connected() { return channel_ != nullptr; } 52 bool is_connected() { return channel_ != nullptr; }
53 53
54 protected: 54 protected:
55 explicit ChannelDispatcherBase(const char* channel_name); 55 explicit ChannelDispatcherBase(const char* channel_name);
56 56
57 BufferedSocketWriter* writer() { return &writer_; } 57 BufferedSocketWriter* writer() { return &writer_; }
58 MessageReader* reader() { return &reader_; } 58
59 // Should be overridden in child classes to handle incoming messages.
60 virtual void OnIncomingMessage(scoped_ptr<CompoundBuffer> message);
Jamie 2016/01/30 00:56:27 Is the case for not overriding this sufficiently c
Sergey Ulanov 2016/01/30 02:15:48 Some channels are one-directional (events and audi
59 61
60 private: 62 private:
61 void OnChannelReady(scoped_ptr<P2PStreamSocket> socket); 63 void OnChannelReady(scoped_ptr<P2PStreamSocket> socket);
62 void OnReadWriteFailed(int error); 64 void OnReadWriteFailed(int error);
63 65
64 std::string channel_name_; 66 std::string channel_name_;
65 StreamChannelFactory* channel_factory_; 67 StreamChannelFactory* channel_factory_;
66 EventHandler* event_handler_; 68 EventHandler* event_handler_;
67 scoped_ptr<P2PStreamSocket> channel_; 69 scoped_ptr<P2PStreamSocket> channel_;
68 70
69 BufferedSocketWriter writer_; 71 BufferedSocketWriter writer_;
70 MessageReader reader_; 72 MessageReader reader_;
71 73
72 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); 74 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase);
73 }; 75 };
74 76
75 } // namespace protocol 77 } // namespace protocol
76 } // namespace remoting 78 } // namespace remoting
77 79
78 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ 80 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698