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

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

Issue 2632803002: Remove all blimp network code. (Closed)
Patch Set: merge from origin/master for good measure Created 3 years, 11 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
(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 #include "blimp/net/blimp_message_demultiplexer.h"
6
7 #include <string>
8
9 #include "base/strings/stringprintf.h"
10 #include "blimp/common/logging.h"
11 #include "blimp/net/common.h"
12 #include "net/base/net_errors.h"
13
14 namespace blimp {
15
16 BlimpMessageDemultiplexer::BlimpMessageDemultiplexer() {}
17
18 BlimpMessageDemultiplexer::~BlimpMessageDemultiplexer() {}
19
20 void BlimpMessageDemultiplexer::AddProcessor(
21 BlimpMessage::FeatureCase feature_case,
22 BlimpMessageProcessor* receiver) {
23 DCHECK(receiver);
24 if (feature_receiver_map_.find(feature_case) == feature_receiver_map_.end()) {
25 feature_receiver_map_.insert(std::make_pair(feature_case, receiver));
26 } else {
27 DLOG(FATAL) << "Handler already registered for feature=" << feature_case
28 << ".";
29 }
30 }
31
32 void BlimpMessageDemultiplexer::ProcessMessage(
33 std::unique_ptr<BlimpMessage> message,
34 const net::CompletionCallback& callback) {
35 DVLOG(2) << "ProcessMessage : " << *message;
36 auto receiver_iter = feature_receiver_map_.find(message->feature_case());
37 if (receiver_iter == feature_receiver_map_.end()) {
38 DLOG(ERROR) << "No registered receiver for " << *message << ".";
39 if (!callback.is_null()) {
40 callback.Run(net::ERR_NOT_IMPLEMENTED);
41 }
42 return;
43 }
44
45 DVLOG(2) << "Routed message " << *message << ".";
46 receiver_iter->second->ProcessMessage(std::move(message), callback);
47 }
48
49 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_message_demultiplexer.h ('k') | blimp/net/blimp_message_demultiplexer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698