Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "chrome/common/message_router.h" |
michael@0 | 6 | |
michael@0 | 7 | void MessageRouter::OnControlMessageReceived(const IPC::Message& msg) { |
michael@0 | 8 | NOTREACHED() << |
michael@0 | 9 | "should override in subclass if you care about control messages"; |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | bool MessageRouter::Send(IPC::Message* msg) { |
michael@0 | 13 | NOTREACHED() << |
michael@0 | 14 | "should override in subclass if you care about sending messages"; |
michael@0 | 15 | return false; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | void MessageRouter::AddRoute(int32_t routing_id, |
michael@0 | 19 | IPC::Channel::Listener* listener) { |
michael@0 | 20 | routes_.AddWithID(listener, routing_id); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | void MessageRouter::RemoveRoute(int32_t routing_id) { |
michael@0 | 24 | routes_.Remove(routing_id); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | void MessageRouter::OnMessageReceived(const IPC::Message& msg) { |
michael@0 | 28 | if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
michael@0 | 29 | OnControlMessageReceived(msg); |
michael@0 | 30 | } else { |
michael@0 | 31 | RouteMessage(msg); |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | bool MessageRouter::RouteMessage(const IPC::Message& msg) { |
michael@0 | 36 | IPC::Channel::Listener* listener = routes_.Lookup(msg.routing_id()); |
michael@0 | 37 | if (!listener) |
michael@0 | 38 | return false; |
michael@0 | 39 | |
michael@0 | 40 | listener->OnMessageReceived(msg); |
michael@0 | 41 | return true; |
michael@0 | 42 | } |