| 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/proto/mux.pb.h" | 9 #include "remoting/proto/mux.pb.h" |
| 10 #include "remoting/protocol/buffered_socket_writer.h" | 10 #include "remoting/protocol/buffered_socket_writer.h" |
| 11 #include "remoting/protocol/channel_factory.h" |
| 11 #include "remoting/protocol/message_reader.h" | 12 #include "remoting/protocol/message_reader.h" |
| 12 #include "remoting/protocol/stream_channel_factory.h" | |
| 13 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 namespace protocol { | 15 namespace protocol { |
| 16 | 16 |
| 17 class ChannelMultiplexer : public StreamChannelFactory { | 17 class ChannelMultiplexer : public ChannelFactory { |
| 18 public: | 18 public: |
| 19 static const char kMuxChannelName[]; | 19 static const char kMuxChannelName[]; |
| 20 | 20 |
| 21 // |factory| is used to create the channel upon which to multiplex. | 21 // |factory| is used to create the channel upon which to multiplex. |
| 22 ChannelMultiplexer(StreamChannelFactory* factory, | 22 ChannelMultiplexer(ChannelFactory* factory, |
| 23 const std::string& base_channel_name); | 23 const std::string& base_channel_name); |
| 24 virtual ~ChannelMultiplexer(); | 24 virtual ~ChannelMultiplexer(); |
| 25 | 25 |
| 26 // StreamChannelFactory interface. | 26 // ChannelFactory interface. |
| 27 virtual void CreateChannel(const std::string& name, | 27 virtual void CreateChannel(const std::string& name, |
| 28 const ChannelCreatedCallback& callback) OVERRIDE; | 28 const ChannelCreatedCallback& callback) OVERRIDE; |
| 29 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 29 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 struct PendingChannel; | 32 struct PendingChannel; |
| 33 class MuxChannel; | 33 class MuxChannel; |
| 34 class MuxSocket; | 34 class MuxSocket; |
| 35 friend class MuxChannel; | 35 friend class MuxChannel; |
| 36 | 36 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 // Callback for |reader_; | 52 // Callback for |reader_; |
| 53 void OnIncomingPacket(scoped_ptr<MultiplexPacket> packet, | 53 void OnIncomingPacket(scoped_ptr<MultiplexPacket> packet, |
| 54 const base::Closure& done_task); | 54 const base::Closure& done_task); |
| 55 | 55 |
| 56 // Called by MuxChannel. | 56 // Called by MuxChannel. |
| 57 bool DoWrite(scoped_ptr<MultiplexPacket> packet, | 57 bool DoWrite(scoped_ptr<MultiplexPacket> packet, |
| 58 const base::Closure& done_task); | 58 const base::Closure& done_task); |
| 59 | 59 |
| 60 // Factory used to create |base_channel_|. Set to NULL once creation is | 60 // Factory used to create |base_channel_|. Set to NULL once creation is |
| 61 // finished or failed. | 61 // finished or failed. |
| 62 StreamChannelFactory* base_channel_factory_; | 62 ChannelFactory* base_channel_factory_; |
| 63 | 63 |
| 64 // Name of the underlying channel. | 64 // Name of the underlying channel. |
| 65 std::string base_channel_name_; | 65 std::string base_channel_name_; |
| 66 | 66 |
| 67 // The channel over which to multiplex. | 67 // The channel over which to multiplex. |
| 68 scoped_ptr<net::StreamSocket> base_channel_; | 68 scoped_ptr<net::StreamSocket> base_channel_; |
| 69 | 69 |
| 70 // List of requested channels while we are waiting for |base_channel_|. | 70 // List of requested channels while we are waiting for |base_channel_|. |
| 71 std::list<PendingChannel> pending_channels_; | 71 std::list<PendingChannel> pending_channels_; |
| 72 | 72 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_; | 83 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer); | 85 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 } // namespace protocol | 88 } // namespace protocol |
| 89 } // namespace remoting | 89 } // namespace remoting |
| 90 | 90 |
| 91 | 91 |
| 92 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ | 92 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ |
| OLD | NEW |