| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ |
| 6 #define BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "blimp/common/proto/blimp_message.pb.h" |
| 11 #include "blimp/net/blimp_message_processor.h" |
| 12 #include "blimp/net/blimp_net_export.h" |
| 13 #include "net/base/completion_callback.h" |
| 14 |
| 15 namespace blimp { |
| 16 |
| 17 class BlimpConnection; |
| 18 class BlimpMessageBuffer; |
| 19 |
| 20 // Creates MessageProcessors that take outgoing messages and multiplex them |
| 21 // on to a single output message processor. |
| 22 class BLIMP_NET_EXPORT BlimpMessageMultiplexer : private BlimpMessageProcessor { |
| 23 public: |
| 24 explicit BlimpMessageMultiplexer(scoped_ptr<BlimpMessageProcessor> output); |
| 25 |
| 26 ~BlimpMessageMultiplexer() override; |
| 27 |
| 28 // Creates a BlimpMessageProcessor object that may only receive messages of |
| 29 // type |type|. This object is used by features for sending messages. |
| 30 scoped_ptr<BlimpMessageProcessor> CreateProcessorForType( |
| 31 BlimpMessage::Type type); |
| 32 |
| 33 private: |
| 34 class MultiplexedSender : public BlimpMessageProcessor { |
| 35 public: |
| 36 MultiplexedSender(BlimpMessageBuffer* output, BlimpMessage::Type type); |
| 37 |
| 38 ~MultiplexedSender() override; |
| 39 |
| 40 // BlimpMessageProcessor implementation. |
| 41 void ProcessMessage(const BlimpMessage& message, |
| 42 const net::CompletionCallback& callback) override; |
| 43 |
| 44 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(MultiplexedSender); |
| 46 }; |
| 47 friend class MultiplexedSender; |
| 48 |
| 49 // BlimpMessageProcessor implementation. |
| 50 // Private linkage so that only MultiplexedSender may call it. |
| 51 void ProcessMessage(const BlimpMessage& message, |
| 52 const net::CompletionCallback& callback) override; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(BlimpMessageMultiplexer); |
| 55 }; |
| 56 |
| 57 } // namespace blimp |
| 58 |
| 59 #endif // BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ |
| OLD | NEW |