| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ | 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ |
| 6 #define BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ | 6 #define BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "blimp/common/proto/blimp_message.pb.h" | 12 #include "blimp/common/proto/blimp_message.pb.h" |
| 13 #include "blimp/net/blimp_net_export.h" | 13 #include "blimp/net/blimp_net_export.h" |
| 14 | 14 |
| 15 namespace blimp { | 15 namespace blimp { |
| 16 | 16 |
| 17 class BlimpConnection; | |
| 18 class BlimpMessageProcessor; | 17 class BlimpMessageProcessor; |
| 19 | 18 |
| 20 // Creates MessageProcessors that receive outgoing messages and put them | 19 // Creates MessageProcessors that receive outgoing messages and put them |
| 21 // onto a multiplexed message stream. | 20 // onto a multiplexed message stream. |
| 22 // BlimpMessageMultiplexer is created on the UI thread, and then used and | 21 // BlimpMessageMultiplexer is created on the UI thread, and then used and |
| 23 // destroyed on the IO thread. | 22 // destroyed on the IO thread. |
| 24 class BLIMP_NET_EXPORT BlimpMessageMultiplexer { | 23 class BLIMP_NET_EXPORT BlimpMessageMultiplexer { |
| 25 public: | 24 public: |
| 26 // |output_processor|: A pointer to the MessageProcessor that will receive the | 25 // |output_processor|: A pointer to the MessageProcessor that will receive the |
| 27 // multiplexed message stream. | 26 // multiplexed message stream. |
| 28 explicit BlimpMessageMultiplexer(BlimpMessageProcessor* output_processor); | 27 explicit BlimpMessageMultiplexer(BlimpMessageProcessor* output_processor); |
| 29 | 28 |
| 30 ~BlimpMessageMultiplexer(); | 29 ~BlimpMessageMultiplexer(); |
| 31 | 30 |
| 32 // Creates a BlimpMessageProcessor object for sending messages of type | 31 // Creates a BlimpMessageProcessor object for sending messages of type |
| 33 // |feature_case|. Any number of senders can be created at a time for a given | 32 // |feature_case|. Any number of senders can be created at a time for a given |
| 34 // type. | 33 // type. |
| 35 std::unique_ptr<BlimpMessageProcessor> CreateSender( | 34 std::unique_ptr<BlimpMessageProcessor> CreateSender( |
| 36 BlimpMessage::FeatureCase feature_case); | 35 BlimpMessage::FeatureCase feature_case); |
| 37 | 36 |
| 38 private: | 37 private: |
| 39 base::WeakPtrFactory<BlimpMessageProcessor> output_weak_factory_; | 38 base::WeakPtrFactory<BlimpMessageProcessor> output_weak_factory_; |
| 40 | 39 |
| 41 DISALLOW_COPY_AND_ASSIGN(BlimpMessageMultiplexer); | 40 DISALLOW_COPY_AND_ASSIGN(BlimpMessageMultiplexer); |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 } // namespace blimp | 43 } // namespace blimp |
| 45 | 44 |
| 46 #endif // BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ | 45 #endif // BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ |
| OLD | NEW |