Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/common/message_router.h

Issue 1625015: Refactor ChildProcess and related classes to create a framework outside of br... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/child_thread.cc ('k') | chrome/common/message_router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_COMMON_MESSAGE_ROUTER_H__
6 #define CHROME_COMMON_MESSAGE_ROUTER_H__
7
8 #include "base/id_map.h"
9 #include "ipc/ipc_channel.h"
10
11 // The MessageRouter handles all incoming messages sent to it by routing them
12 // to the correct listener. Routing is based on the Message's routing ID.
13 // Since routing IDs are typically assigned asynchronously by the browser
14 // process, the MessageRouter has the notion of pending IDs for listeners that
15 // have not yet been assigned a routing ID.
16 //
17 // When a message arrives, the routing ID is used to index the set of routes to
18 // find a listener. If a listener is found, then the message is passed to it.
19 // Otherwise, the message is ignored if its routing ID is not equal to
20 // MSG_ROUTING_CONTROL.
21 //
22 // The MessageRouter supports the IPC::Message::Sender interface for outgoing
23 // messages, but does not define a meaningful implementation of it. The
24 // subclass of MessageRouter is intended to provide that if appropriate.
25 //
26 // The MessageRouter can be used as a concrete class provided its Send method
27 // is not called and it does not receive any control messages.
28
29 class MessageRouter : public IPC::Channel::Listener,
30 public IPC::Message::Sender {
31 public:
32 MessageRouter() {}
33 virtual ~MessageRouter() {}
34
35 // Implemented by subclasses to handle control messages
36 virtual void OnControlMessageReceived(const IPC::Message& msg);
37
38 // IPC::Channel::Listener implementation:
39 virtual void OnMessageReceived(const IPC::Message& msg);
40
41 // Like OnMessageReceived, except it only handles routed messages. Returns
42 // true if the message was dispatched, or false if there was no listener for
43 // that route id.
44 virtual bool RouteMessage(const IPC::Message& msg);
45
46 // IPC::Message::Sender implementation:
47 virtual bool Send(IPC::Message* msg);
48
49 // Called to add/remove a listener for a particular message routing ID.
50 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
51 void RemoveRoute(int32 routing_id);
52
53 IPC::Channel::Listener* ResolveRoute(int32 routing_id);
54
55 private:
56 // A list of all listeners with assigned routing IDs.
57 IDMap<IPC::Channel::Listener> routes_;
58
59 DISALLOW_COPY_AND_ASSIGN(MessageRouter);
60 };
61
62 #endif // CHROME_COMMON_MESSAGE_ROUTER_H__
OLDNEW
« no previous file with comments | « chrome/common/child_thread.cc ('k') | chrome/common/message_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698