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

Side by Side Diff: remoting/protocol/channel_multiplexer.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_MULTIPLEXER_H_ 5 #ifndef REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_
6 #define REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ 6 #define REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "remoting/base/buffered_socket_writer.h" 10 #include "remoting/base/buffered_socket_writer.h"
11 #include "remoting/proto/mux.pb.h" 11 #include "remoting/proto/mux.pb.h"
12 #include "remoting/protocol/message_reader.h" 12 #include "remoting/protocol/message_reader.h"
13 #include "remoting/protocol/protobuf_message_parser.h"
14 #include "remoting/protocol/stream_channel_factory.h" 13 #include "remoting/protocol/stream_channel_factory.h"
15 14
16 namespace remoting { 15 namespace remoting {
17 namespace protocol { 16 namespace protocol {
18 17
19 class ChannelMultiplexer : public StreamChannelFactory { 18 class ChannelMultiplexer : public StreamChannelFactory {
20 public: 19 public:
21 static const char kMuxChannelName[]; 20 static const char kMuxChannelName[];
22 21
23 // |factory| is used to create the channel upon which to multiplex. 22 // |factory| is used to create the channel upon which to multiplex.
(...skipping 22 matching lines...) Expand all
46 MuxChannel* GetOrCreateChannel(const std::string& name); 45 MuxChannel* GetOrCreateChannel(const std::string& name);
47 46
48 // Error handling callback for |reader_| and |writer_|. 47 // Error handling callback for |reader_| and |writer_|.
49 void OnBaseChannelError(int error); 48 void OnBaseChannelError(int error);
50 49
51 // Propagates base channel error to channel |name|, queued asynchronously by 50 // Propagates base channel error to channel |name|, queued asynchronously by
52 // OnBaseChannelError(). 51 // OnBaseChannelError().
53 void NotifyBaseChannelError(const std::string& name, int error); 52 void NotifyBaseChannelError(const std::string& name, int error);
54 53
55 // Callback for |reader_; 54 // Callback for |reader_;
56 void OnIncomingPacket(scoped_ptr<MultiplexPacket> packet); 55 void OnIncomingPacket(scoped_ptr<CompoundBuffer> buffer);
57 56
58 // Called by MuxChannel. 57 // Called by MuxChannel.
59 void DoWrite(scoped_ptr<MultiplexPacket> packet, 58 void DoWrite(scoped_ptr<MultiplexPacket> packet,
60 const base::Closure& done_task); 59 const base::Closure& done_task);
61 60
62 // Factory used to create |base_channel_|. Set to nullptr once creation is 61 // Factory used to create |base_channel_|. Set to nullptr once creation is
63 // finished or failed. 62 // finished or failed.
64 StreamChannelFactory* base_channel_factory_; 63 StreamChannelFactory* base_channel_factory_;
65 64
66 // Name of the underlying channel. 65 // Name of the underlying channel.
67 std::string base_channel_name_; 66 std::string base_channel_name_;
68 67
69 // The channel over which to multiplex. 68 // The channel over which to multiplex.
70 scoped_ptr<P2PStreamSocket> base_channel_; 69 scoped_ptr<P2PStreamSocket> base_channel_;
71 70
72 // List of requested channels while we are waiting for |base_channel_|. 71 // List of requested channels while we are waiting for |base_channel_|.
73 std::list<PendingChannel> pending_channels_; 72 std::list<PendingChannel> pending_channels_;
74 73
75 int next_channel_id_; 74 int next_channel_id_;
76 std::map<std::string, MuxChannel*> channels_; 75 std::map<std::string, MuxChannel*> channels_;
77 76
78 // Channels are added to |channels_by_receive_id_| only after we receive 77 // Channels are added to |channels_by_receive_id_| only after we receive
79 // receive_id from the remote peer. 78 // receive_id from the remote peer.
80 std::map<int, MuxChannel*> channels_by_receive_id_; 79 std::map<int, MuxChannel*> channels_by_receive_id_;
81 80
82 BufferedSocketWriter writer_; 81 BufferedSocketWriter writer_;
83 MessageReader reader_; 82 MessageReader reader_;
84 ProtobufMessageParser<MultiplexPacket> parser_;
85 83
86 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_; 84 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_;
87 85
88 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer); 86 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer);
89 }; 87 };
90 88
91 } // namespace protocol 89 } // namespace protocol
92 } // namespace remoting 90 } // namespace remoting
93 91
94 92
95 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ 93 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698