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

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

Issue 1551583003: Implementation and fixes for Blimp client/engine E2E communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dtrainor-linux-cl1528243002
Patch Set: Fixed misplaced EXPORT directive Created 4 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
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 #include "blimp/net/blimp_message_demultiplexer.h" 5 #include "blimp/net/blimp_message_demultiplexer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "blimp/net/common.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 12
12 namespace blimp { 13 namespace blimp {
13 namespace {
14
15 std::string BlimpMessageToDebugString(const BlimpMessage& message) {
16 return base::StringPrintf("<message type=%d>", message.type());
17 }
18
19 } // namespace
20 14
21 BlimpMessageDemultiplexer::BlimpMessageDemultiplexer() {} 15 BlimpMessageDemultiplexer::BlimpMessageDemultiplexer() {}
22 16
23 BlimpMessageDemultiplexer::~BlimpMessageDemultiplexer() {} 17 BlimpMessageDemultiplexer::~BlimpMessageDemultiplexer() {}
24 18
25 void BlimpMessageDemultiplexer::AddProcessor(BlimpMessage::Type type, 19 void BlimpMessageDemultiplexer::AddProcessor(BlimpMessage::Type type,
26 BlimpMessageProcessor* receiver) { 20 BlimpMessageProcessor* receiver) {
27 DCHECK(receiver); 21 DCHECK(receiver);
28 if (feature_receiver_map_.find(type) == feature_receiver_map_.end()) { 22 if (feature_receiver_map_.find(type) == feature_receiver_map_.end()) {
29 feature_receiver_map_.insert(std::make_pair(type, receiver)); 23 feature_receiver_map_.insert(std::make_pair(type, receiver));
30 } else { 24 } else {
31 DLOG(FATAL) << "Handler already registered for type=" << type << "."; 25 DLOG(FATAL) << "Handler already registered for type=" << type << ".";
32 } 26 }
33 } 27 }
34 28
35 void BlimpMessageDemultiplexer::ProcessMessage( 29 void BlimpMessageDemultiplexer::ProcessMessage(
36 scoped_ptr<BlimpMessage> message, 30 scoped_ptr<BlimpMessage> message,
37 const net::CompletionCallback& callback) { 31 const net::CompletionCallback& callback) {
38 auto receiver_iter = feature_receiver_map_.find(message->type()); 32 auto receiver_iter = feature_receiver_map_.find(message->type());
39 if (receiver_iter == feature_receiver_map_.end()) { 33 if (receiver_iter == feature_receiver_map_.end()) {
40 DLOG(FATAL) << "No registered receiver for " 34 DLOG(ERROR) << "No registered receiver for " << *message << ".";
41 << BlimpMessageToDebugString(*message) << ".";
42 if (!callback.is_null()) { 35 if (!callback.is_null()) {
43 callback.Run(net::ERR_NOT_IMPLEMENTED); 36 callback.Run(net::ERR_NOT_IMPLEMENTED);
44 } 37 }
38 return;
45 } 39 }
46 40
47 receiver_iter->second->ProcessMessage(std::move(message), callback); 41 receiver_iter->second->ProcessMessage(std::move(message), callback);
48 } 42 }
49 43
50 } // namespace blimp 44 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_connection_unittest.cc ('k') | blimp/net/blimp_message_demultiplexer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698