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

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

Issue 1429193002: Add interfaces for most major Blimp net components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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
OLDNEW
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_DISPATCHER_H_ 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_
6 #define BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_ 6 #define BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/containers/small_map.h" 10 #include "base/containers/small_map.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "blimp/common/proto/blimp_message.pb.h" 12 #include "blimp/common/proto/blimp_message.pb.h"
13 #include "blimp/net/blimp_message_receiver.h" 13 #include "blimp/net/blimp_message_processor.h"
14 #include "blimp/net/blimp_net_export.h" 14 #include "blimp/net/blimp_net_export.h"
15 15
16 namespace blimp { 16 namespace blimp {
17 17
18 // Multiplexing BlimpMessageReceiver which routes BlimpMessages to other 18 // Multiplexing BlimpMessageProcessor which routes BlimpMessages to other
19 // receivers based on the messages' feature type. 19 // processors based on the messages' feature type.
20 class BLIMP_NET_EXPORT BlimpMessageDispatcher : public BlimpMessageReceiver { 20 class BLIMP_NET_EXPORT BlimpMessageDispatcher : public BlimpMessageProcessor {
21 public: 21 public:
22 BlimpMessageDispatcher(); 22 BlimpMessageDispatcher();
23 ~BlimpMessageDispatcher() override; 23 ~BlimpMessageDispatcher() override;
24 24
25 // Registers a message receiver which will process all messages 25 // Registers a message receiver which will process all messages
26 // with of the specified |type|. 26 // with of the specified |type|.
27 // Only one handler may be added per type. 27 // Only one handler may be added per type.
28 // 28 //
29 // |handler| must be valid when OnBlimpMessage() is called. 29 // |handler| must be valid when OnBlimpMessage() is called.
30 void AddReceiver(BlimpMessage::Type type, BlimpMessageReceiver* handler); 30 void AddReceiver(BlimpMessage::Type type, BlimpMessageProcessor* handler);
31 31
32 // BlimpMessageReceiver implementation. 32 // BlimpMessageProcessor implementation.
33 net::Error OnBlimpMessage(const BlimpMessage& message) override; 33 void ProcessMessage(const BlimpMessage& message,
34 const net::CompletionCallback& callback) override;
34 35
35 private: 36 private:
36 base::SmallMap<std::map<BlimpMessage::Type, BlimpMessageReceiver*>> 37 base::SmallMap<std::map<BlimpMessage::Type, BlimpMessageProcessor*>>
37 feature_receiver_map_; 38 feature_receiver_map_;
38 39
39 DISALLOW_COPY_AND_ASSIGN(BlimpMessageDispatcher); 40 DISALLOW_COPY_AND_ASSIGN(BlimpMessageDispatcher);
40 }; 41 };
41 42
42 } // namespace blimp 43 } // namespace blimp
43 44
44 #endif // BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_ 45 #endif // BLIMP_NET_BLIMP_MESSAGE_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698