Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: blimp/net/blimp_message_dispatcher.h

Issue 1324263003: Blimp: create MessageDispatcher class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp-protos
Patch Set: Resolve naming collision for "net" Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/net/BUILD.gn ('k') | blimp/net/blimp_message_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_DISPATCHER_H_
6 #define BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_
7
8 #include <map>
9
10 #include "base/containers/small_map.h"
11 #include "base/threading/thread_checker.h"
12 #include "blimp/common/proto/blimp_message.pb.h"
13 #include "blimp/net/blimp_message_receiver.h"
14 #include "blimp/net/blimp_net_export.h"
15
16 namespace blimp {
17
18 // Multiplexing BlimpMessageReceiver which routes BlimpMessages to other
19 // receivers based on the messages' feature type.
20 class BLIMP_NET_EXPORT BlimpMessageDispatcher : public BlimpMessageReceiver {
21 public:
22 BlimpMessageDispatcher();
23 ~BlimpMessageDispatcher() override;
24
25 // Registers a message receiver which will process all messages
26 // with of the specified |type|.
27 // Only one handler may be added per type.
28 //
29 // |handler| must be valid when OnBlimpMessage() is called.
30 void AddReceiver(BlimpMessage::Type type, BlimpMessageReceiver* handler);
31
32 // BlimpMessageReceiver implementation.
33 net::Error OnBlimpMessage(const BlimpMessage& message) override;
34
35 private:
36 base::SmallMap<std::map<BlimpMessage::Type, BlimpMessageReceiver*>>
37 feature_receiver_map_;
38
39 DISALLOW_COPY_AND_ASSIGN(BlimpMessageDispatcher);
40 };
41
42 } // namespace blimp
43
44 #endif // BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_
OLDNEW
« no previous file with comments | « blimp/net/BUILD.gn ('k') | blimp/net/blimp_message_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698