IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / common / message_router.cc
blobf73e6543eb4e5b5ecc80096bfa9f6bc28fa2938f
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
3 // found in the LICENSE file.
5 #include "content/common/message_router.h"
7 #include "ipc/ipc_message.h"
9 namespace content {
11 MessageRouter::MessageRouter() {
14 MessageRouter::~MessageRouter() {
17 bool MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
18 NOTREACHED() <<
19 "should override in subclass if you care about control messages";
20 return false;
23 bool MessageRouter::Send(IPC::Message* msg) {
24 NOTREACHED() <<
25 "should override in subclass if you care about sending messages";
26 return false;
29 void MessageRouter::AddRoute(int32 routing_id, IPC::Listener* listener) {
30 routes_.AddWithID(listener, routing_id);
33 void MessageRouter::RemoveRoute(int32 routing_id) {
34 routes_.Remove(routing_id);
37 bool MessageRouter::OnMessageReceived(const IPC::Message& msg) {
38 if (msg.routing_id() == MSG_ROUTING_CONTROL)
39 return OnControlMessageReceived(msg);
41 return RouteMessage(msg);
44 bool MessageRouter::RouteMessage(const IPC::Message& msg) {
45 IPC::Listener* listener = routes_.Lookup(msg.routing_id());
46 if (!listener)
47 return false;
49 listener->OnMessageReceived(msg);
50 return true;
53 } // namespace content