OLD | NEW |
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/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "remoting/base/buffered_socket_writer.h" | 9 #include "remoting/base/buffered_socket_writer.h" |
10 #include "remoting/proto/mux.pb.h" | 10 #include "remoting/proto/mux.pb.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const ChannelCreatedCallback& callback) override; | 29 const ChannelCreatedCallback& callback) override; |
30 void CancelChannelCreation(const std::string& name) override; | 30 void CancelChannelCreation(const std::string& name) override; |
31 | 31 |
32 private: | 32 private: |
33 struct PendingChannel; | 33 struct PendingChannel; |
34 class MuxChannel; | 34 class MuxChannel; |
35 class MuxSocket; | 35 class MuxSocket; |
36 friend class MuxChannel; | 36 friend class MuxChannel; |
37 | 37 |
38 // Callback for |base_channel_| creation. | 38 // Callback for |base_channel_| creation. |
39 void OnBaseChannelReady(scoped_ptr<net::StreamSocket> socket); | 39 void OnBaseChannelReady(scoped_ptr<P2PStreamSocket> socket); |
40 | 40 |
41 // Helper to create channels asynchronously. | 41 // Helper to create channels asynchronously. |
42 void DoCreatePendingChannels(); | 42 void DoCreatePendingChannels(); |
43 | 43 |
44 // Helper method used to create channels. | 44 // Helper method used to create channels. |
45 MuxChannel* GetOrCreateChannel(const std::string& name); | 45 MuxChannel* GetOrCreateChannel(const std::string& name); |
46 | 46 |
47 // Error handling callback for |reader_| and |writer_|. | 47 // Error handling callback for |reader_| and |writer_|. |
48 void OnBaseChannelError(int error); | 48 void OnBaseChannelError(int error); |
49 | 49 |
(...skipping 10 matching lines...) Expand all Loading... |
60 const base::Closure& done_task); | 60 const base::Closure& done_task); |
61 | 61 |
62 // Factory used to create |base_channel_|. Set to nullptr once creation is | 62 // Factory used to create |base_channel_|. Set to nullptr once creation is |
63 // finished or failed. | 63 // finished or failed. |
64 StreamChannelFactory* base_channel_factory_; | 64 StreamChannelFactory* base_channel_factory_; |
65 | 65 |
66 // Name of the underlying channel. | 66 // Name of the underlying channel. |
67 std::string base_channel_name_; | 67 std::string base_channel_name_; |
68 | 68 |
69 // The channel over which to multiplex. | 69 // The channel over which to multiplex. |
70 scoped_ptr<net::StreamSocket> base_channel_; | 70 scoped_ptr<P2PStreamSocket> base_channel_; |
71 | 71 |
72 // List of requested channels while we are waiting for |base_channel_|. | 72 // List of requested channels while we are waiting for |base_channel_|. |
73 std::list<PendingChannel> pending_channels_; | 73 std::list<PendingChannel> pending_channels_; |
74 | 74 |
75 int next_channel_id_; | 75 int next_channel_id_; |
76 std::map<std::string, MuxChannel*> channels_; | 76 std::map<std::string, MuxChannel*> channels_; |
77 | 77 |
78 // Channels are added to |channels_by_receive_id_| only after we receive | 78 // Channels are added to |channels_by_receive_id_| only after we receive |
79 // receive_id from the remote peer. | 79 // receive_id from the remote peer. |
80 std::map<int, MuxChannel*> channels_by_receive_id_; | 80 std::map<int, MuxChannel*> channels_by_receive_id_; |
81 | 81 |
82 BufferedSocketWriter writer_; | 82 BufferedSocketWriter writer_; |
83 MessageReader reader_; | 83 MessageReader reader_; |
84 ProtobufMessageParser<MultiplexPacket> parser_; | 84 ProtobufMessageParser<MultiplexPacket> parser_; |
85 | 85 |
86 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_; | 86 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_; |
87 | 87 |
88 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer); | 88 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer); |
89 }; | 89 }; |
90 | 90 |
91 } // namespace protocol | 91 } // namespace protocol |
92 } // namespace remoting | 92 } // namespace remoting |
93 | 93 |
94 | 94 |
95 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ | 95 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ |
OLD | NEW |