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

Side by Side Diff: content/common/message_router.cc

Issue 10662005: Use IPC::Sender and IPC::Listener in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « content/common/message_router.h ('k') | content/common/np_channel_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/message_router.h" 5 #include "content/common/message_router.h"
6 6
7 #include "ipc/ipc_message.h"
8
7 MessageRouter::MessageRouter() { 9 MessageRouter::MessageRouter() {
8 } 10 }
9 11
10 MessageRouter::~MessageRouter() { 12 MessageRouter::~MessageRouter() {
11 } 13 }
12 14
13 bool MessageRouter::OnControlMessageReceived(const IPC::Message& msg) { 15 bool MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
14 NOTREACHED() << 16 NOTREACHED() <<
15 "should override in subclass if you care about control messages"; 17 "should override in subclass if you care about control messages";
16 return false; 18 return false;
17 } 19 }
18 20
19 bool MessageRouter::Send(IPC::Message* msg) { 21 bool MessageRouter::Send(IPC::Message* msg) {
20 NOTREACHED() << 22 NOTREACHED() <<
21 "should override in subclass if you care about sending messages"; 23 "should override in subclass if you care about sending messages";
22 return false; 24 return false;
23 } 25 }
24 26
25 void MessageRouter::AddRoute(int32 routing_id, 27 void MessageRouter::AddRoute(int32 routing_id, IPC::Listener* listener) {
26 IPC::Channel::Listener* listener) {
27 routes_.AddWithID(listener, routing_id); 28 routes_.AddWithID(listener, routing_id);
28 } 29 }
29 30
30 void MessageRouter::RemoveRoute(int32 routing_id) { 31 void MessageRouter::RemoveRoute(int32 routing_id) {
31 routes_.Remove(routing_id); 32 routes_.Remove(routing_id);
32 } 33 }
33 34
34 bool MessageRouter::OnMessageReceived(const IPC::Message& msg) { 35 bool MessageRouter::OnMessageReceived(const IPC::Message& msg) {
35 if (msg.routing_id() == MSG_ROUTING_CONTROL) 36 if (msg.routing_id() == MSG_ROUTING_CONTROL)
36 return OnControlMessageReceived(msg); 37 return OnControlMessageReceived(msg);
37 38
38 return RouteMessage(msg); 39 return RouteMessage(msg);
39 } 40 }
40 41
41 bool MessageRouter::RouteMessage(const IPC::Message& msg) { 42 bool MessageRouter::RouteMessage(const IPC::Message& msg) {
42 IPC::Channel::Listener* listener = ResolveRoute(msg.routing_id()); 43 IPC::Listener* listener = ResolveRoute(msg.routing_id());
43 if (!listener) 44 if (!listener)
44 return false; 45 return false;
45 46
46 listener->OnMessageReceived(msg); 47 listener->OnMessageReceived(msg);
47 return true; 48 return true;
48 } 49 }
49 50
50 IPC::Channel::Listener* MessageRouter::ResolveRoute(int32 routing_id) { 51 IPC::Listener* MessageRouter::ResolveRoute(int32 routing_id) {
51 return routes_.Lookup(routing_id); 52 return routes_.Lookup(routing_id);
52 } 53 }
OLDNEW
« no previous file with comments | « content/common/message_router.h ('k') | content/common/np_channel_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698