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

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

Issue 1933053003: Used oneof in blimp_message.proto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 7 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
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_DEMULTIPLEXER_H_ 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_DEMULTIPLEXER_H_
6 #define BLIMP_NET_BLIMP_MESSAGE_DEMULTIPLEXER_H_ 6 #define BLIMP_NET_BLIMP_MESSAGE_DEMULTIPLEXER_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/macros.h" 11 #include "base/macros.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "blimp/common/proto/blimp_message.pb.h" 13 #include "blimp/common/proto/blimp_message.pb.h"
14 #include "blimp/net/blimp_message_processor.h" 14 #include "blimp/net/blimp_message_processor.h"
15 #include "blimp/net/blimp_net_export.h" 15 #include "blimp/net/blimp_net_export.h"
16 16
17 namespace blimp { 17 namespace blimp {
18 18
19 // Multiplexing BlimpMessageProcessor which routes BlimpMessages to message 19 // Multiplexing BlimpMessageProcessor which routes BlimpMessages to message
20 // processors based on |message.type|. 20 // processors based on the specific feature.
21 // BlimpMessageDemultiplexer is created on the UI thread, and then used and 21 // BlimpMessageDemultiplexer is created on the UI thread, and then used and
22 // destroyed on the IO thread. 22 // destroyed on the IO thread.
23 class BLIMP_NET_EXPORT BlimpMessageDemultiplexer 23 class BLIMP_NET_EXPORT BlimpMessageDemultiplexer
24 : public BlimpMessageProcessor { 24 : public BlimpMessageProcessor {
25 public: 25 public:
26 BlimpMessageDemultiplexer(); 26 BlimpMessageDemultiplexer();
27 ~BlimpMessageDemultiplexer() override; 27 ~BlimpMessageDemultiplexer() override;
28 28
29 // Registers a message processor which will receive all messages 29 // Registers a message processor which will receive all messages
30 // of the |type| specified. 30 // of the |feature_case| specified.
31 // Only one handler may be added per type. 31 // Only one handler may be added per type.
32 // 32 //
33 // |handler| must be valid when ProcessMessage() is called. 33 // |handler| must be valid when ProcessMessage() is called.
34 void AddProcessor(BlimpMessage::Type type, BlimpMessageProcessor* handler); 34 void AddProcessor(BlimpMessage::FeatureCase feature_case,
35 BlimpMessageProcessor* handler);
35 36
36 // BlimpMessageProcessor implementation. 37 // BlimpMessageProcessor implementation.
37 void ProcessMessage(std::unique_ptr<BlimpMessage> message, 38 void ProcessMessage(std::unique_ptr<BlimpMessage> message,
38 const net::CompletionCallback& callback) override; 39 const net::CompletionCallback& callback) override;
39 40
40 private: 41 private:
41 base::SmallMap<std::map<BlimpMessage::Type, BlimpMessageProcessor*>> 42 base::SmallMap<std::map<BlimpMessage::FeatureCase, BlimpMessageProcessor*>>
42 feature_receiver_map_; 43 feature_receiver_map_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(BlimpMessageDemultiplexer); 45 DISALLOW_COPY_AND_ASSIGN(BlimpMessageDemultiplexer);
45 }; 46 };
46 47
47 } // namespace blimp 48 } // namespace blimp
48 49
49 #endif // BLIMP_NET_BLIMP_MESSAGE_DEMULTIPLEXER_H_ 50 #endif // BLIMP_NET_BLIMP_MESSAGE_DEMULTIPLEXER_H_
OLDNEW
« no previous file with comments | « blimp/net/blimp_message_checkpointer_unittest.cc ('k') | blimp/net/blimp_message_demultiplexer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698