| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_COMMON_MESSAGE_ROUTER_H__ | 5 #ifndef CHROME_COMMON_MESSAGE_ROUTER_H__ |
| 6 #define CHROME_COMMON_MESSAGE_ROUTER_H__ | 6 #define CHROME_COMMON_MESSAGE_ROUTER_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
| 10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // The MessageRouter can be used as a concrete class provided its Send method | 27 // The MessageRouter can be used as a concrete class provided its Send method |
| 28 // is not called and it does not receive any control messages. | 28 // is not called and it does not receive any control messages. |
| 29 | 29 |
| 30 class MessageRouter : public IPC::Channel::Listener, | 30 class MessageRouter : public IPC::Channel::Listener, |
| 31 public IPC::Message::Sender { | 31 public IPC::Message::Sender { |
| 32 public: | 32 public: |
| 33 MessageRouter(); | 33 MessageRouter(); |
| 34 virtual ~MessageRouter(); | 34 virtual ~MessageRouter(); |
| 35 | 35 |
| 36 // Implemented by subclasses to handle control messages | 36 // Implemented by subclasses to handle control messages |
| 37 virtual void OnControlMessageReceived(const IPC::Message& msg); | 37 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 38 | 38 |
| 39 // IPC::Channel::Listener implementation: | 39 // IPC::Channel::Listener implementation: |
| 40 virtual void OnMessageReceived(const IPC::Message& msg); | 40 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 41 | 41 |
| 42 // Like OnMessageReceived, except it only handles routed messages. Returns | 42 // Like OnMessageReceived, except it only handles routed messages. Returns |
| 43 // true if the message was dispatched, or false if there was no listener for | 43 // true if the message was dispatched, or false if there was no listener for |
| 44 // that route id. | 44 // that route id. |
| 45 virtual bool RouteMessage(const IPC::Message& msg); | 45 virtual bool RouteMessage(const IPC::Message& msg); |
| 46 | 46 |
| 47 // IPC::Message::Sender implementation: | 47 // IPC::Message::Sender implementation: |
| 48 virtual bool Send(IPC::Message* msg); | 48 virtual bool Send(IPC::Message* msg); |
| 49 | 49 |
| 50 // Called to add/remove a listener for a particular message routing ID. | 50 // Called to add/remove a listener for a particular message routing ID. |
| 51 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 51 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
| 52 void RemoveRoute(int32 routing_id); | 52 void RemoveRoute(int32 routing_id); |
| 53 | 53 |
| 54 IPC::Channel::Listener* ResolveRoute(int32 routing_id); | 54 IPC::Channel::Listener* ResolveRoute(int32 routing_id); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // A list of all listeners with assigned routing IDs. | 57 // A list of all listeners with assigned routing IDs. |
| 58 IDMap<IPC::Channel::Listener> routes_; | 58 IDMap<IPC::Channel::Listener> routes_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(MessageRouter); | 60 DISALLOW_COPY_AND_ASSIGN(MessageRouter); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 #endif // CHROME_COMMON_MESSAGE_ROUTER_H__ | 63 #endif // CHROME_COMMON_MESSAGE_ROUTER_H__ |
| OLD | NEW |