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 | |
19 // Creates MessageProcessors that receive outgoing messages and multiplex them | |
Wez
2015/11/12 00:12:54
nit: Creates->Dispenses?
nit: Suggest dropping "r
Kevin M
2015/11/12 01:53:16
Done.
| |
20 // on to a single output message processor. | |
21 class BLIMP_NET_EXPORT BlimpMessageMultiplexer : public BlimpMessageProcessor { | |
Wez
2015/11/12 00:12:54
This doesn't need to be a BlimpMessageProcessor it
Kevin M
2015/11/12 01:53:16
Propagated changes across branches.
| |
22 public: | |
23 // |output_processor|: A pointer to the MessageProcessor that will receive the | |
24 // multiplexed output of this. | |
Wez
2015/11/12 00:12:54
nit: multiplexed message stream.
Kevin M
2015/11/12 01:53:16
Done.
| |
25 explicit BlimpMessageMultiplexer(BlimpMessageProcessor* output_processor); | |
26 | |
27 ~BlimpMessageMultiplexer() override; | |
28 | |
29 // Creates a BlimpMessageProcessor object for sending messages of type |type|. | |
30 // Any number of senders can be created at a time for a given type. | |
31 scoped_ptr<BlimpMessageProcessor> CreateSenderForType( | |
32 BlimpMessage::Type type); | |
33 | |
34 private: | |
35 class MultiplexedSender : public BlimpMessageProcessor { | |
36 public: | |
37 MultiplexedSender(BlimpMessageMultiplexer* multiplexer, | |
38 BlimpMessage::Type type); | |
39 ~MultiplexedSender() override; | |
40 | |
41 // BlimpMessageProcessor implementation. | |
42 // |message.type| should not be set at the time of calling ProcessMessage. | |
43 void ProcessMessage(const BlimpMessage& message, | |
44 const net::CompletionCallback& callback) override; | |
45 | |
46 private: | |
47 BlimpMessageMultiplexer* multiplexer_; | |
48 BlimpMessage::Type type_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(MultiplexedSender); | |
51 }; | |
52 friend class MultiplexedSender; | |
53 | |
54 // BlimpMessageProcessor implementation. | |
55 // Private linkage so that only MultiplexedSender may call it. | |
56 void ProcessMessage(const BlimpMessage& message, | |
57 const net::CompletionCallback& callback) override; | |
58 | |
59 BlimpMessageProcessor* output_processor_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(BlimpMessageMultiplexer); | |
62 }; | |
63 | |
64 } // namespace blimp | |
65 | |
66 #endif // BLIMP_NET_BLIMP_MESSAGE_MULTIPLEXER_H_ | |
OLD | NEW |