ipc/chromium/src/chrome/common/message_router.cc

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 // Copyright (c) 2006-2008 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 "chrome/common/message_router.h"
     7 void MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
     8   NOTREACHED() <<
     9       "should override in subclass if you care about control messages";
    10 }
    12 bool MessageRouter::Send(IPC::Message* msg) {
    13   NOTREACHED() <<
    14       "should override in subclass if you care about sending messages";
    15   return false;
    16 }
    18 void MessageRouter::AddRoute(int32_t routing_id,
    19                              IPC::Channel::Listener* listener) {
    20   routes_.AddWithID(listener, routing_id);
    21 }
    23 void MessageRouter::RemoveRoute(int32_t routing_id) {
    24   routes_.Remove(routing_id);
    25 }
    27 void MessageRouter::OnMessageReceived(const IPC::Message& msg) {
    28   if (msg.routing_id() == MSG_ROUTING_CONTROL) {
    29     OnControlMessageReceived(msg);
    30   } else {
    31     RouteMessage(msg);
    32   }
    33 }
    35 bool MessageRouter::RouteMessage(const IPC::Message& msg) {
    36   IPC::Channel::Listener* listener = routes_.Lookup(msg.routing_id());
    37   if (!listener)
    38     return false;
    40   listener->OnMessageReceived(msg);
    41   return true;
    42 }

mercurial