| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_COMMON_MESSAGE_ROUTER_H_ | 5 #ifndef CONTENT_COMMON_MESSAGE_ROUTER_H_ |
| 6 #define CONTENT_COMMON_MESSAGE_ROUTER_H_ | 6 #define CONTENT_COMMON_MESSAGE_ROUTER_H_ |
| 7 | 7 |
| 8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "content/common/content_export.h" |
| 9 #include "ipc/ipc_listener.h" | 10 #include "ipc/ipc_listener.h" |
| 10 #include "ipc/ipc_sender.h" | 11 #include "ipc/ipc_sender.h" |
| 11 | 12 |
| 12 // The MessageRouter handles all incoming messages sent to it by routing them | 13 // The MessageRouter handles all incoming messages sent to it by routing them |
| 13 // to the correct listener. Routing is based on the Message's routing ID. | 14 // to the correct listener. Routing is based on the Message's routing ID. |
| 14 // Since routing IDs are typically assigned asynchronously by the browser | 15 // Since routing IDs are typically assigned asynchronously by the browser |
| 15 // process, the MessageRouter has the notion of pending IDs for listeners that | 16 // process, the MessageRouter has the notion of pending IDs for listeners that |
| 16 // have not yet been assigned a routing ID. | 17 // have not yet been assigned a routing ID. |
| 17 // | 18 // |
| 18 // When a message arrives, the routing ID is used to index the set of routes to | 19 // When a message arrives, the routing ID is used to index the set of routes to |
| 19 // find a listener. If a listener is found, then the message is passed to it. | 20 // find a listener. If a listener is found, then the message is passed to it. |
| 20 // Otherwise, the message is ignored if its routing ID is not equal to | 21 // Otherwise, the message is ignored if its routing ID is not equal to |
| 21 // MSG_ROUTING_CONTROL. | 22 // MSG_ROUTING_CONTROL. |
| 22 // | 23 // |
| 23 // The MessageRouter supports the IPC::Sender interface for outgoing messages, | 24 // The MessageRouter supports the IPC::Sender interface for outgoing messages, |
| 24 // but does not define a meaningful implementation of it. The subclass of | 25 // but does not define a meaningful implementation of it. The subclass of |
| 25 // MessageRouter is intended to provide that if appropriate. | 26 // MessageRouter is intended to provide that if appropriate. |
| 26 // | 27 // |
| 27 // The MessageRouter can be used as a concrete class provided its Send method | 28 // 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. | 29 // is not called and it does not receive any control messages. |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 | 32 |
| 32 class MessageRouter : public IPC::Listener, public IPC::Sender { | 33 class CONTENT_EXPORT MessageRouter : public IPC::Listener, public IPC::Sender { |
| 33 public: | 34 public: |
| 34 MessageRouter(); | 35 MessageRouter(); |
| 35 ~MessageRouter() override; | 36 ~MessageRouter() override; |
| 36 | 37 |
| 37 // Implemented by subclasses to handle control messages | 38 // Implemented by subclasses to handle control messages |
| 38 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 39 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 39 | 40 |
| 40 // IPC::Listener implementation: | 41 // IPC::Listener implementation: |
| 41 bool OnMessageReceived(const IPC::Message& msg) override; | 42 bool OnMessageReceived(const IPC::Message& msg) override; |
| 42 | 43 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 private: | 59 private: |
| 59 // A list of all listeners with assigned routing IDs. | 60 // A list of all listeners with assigned routing IDs. |
| 60 IDMap<IPC::Listener> routes_; | 61 IDMap<IPC::Listener> routes_; |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(MessageRouter); | 63 DISALLOW_COPY_AND_ASSIGN(MessageRouter); |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 } // namespace content | 66 } // namespace content |
| 66 | 67 |
| 67 #endif // CONTENT_COMMON_MESSAGE_ROUTER_H_ | 68 #endif // CONTENT_COMMON_MESSAGE_ROUTER_H_ |
| OLD | NEW |