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

Unified Diff: ipc/ipc_forwarding_message_filter.h

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ipc/ipc_forwarding_message_filter.h
diff --git a/ipc/ipc_forwarding_message_filter.h b/ipc/ipc_forwarding_message_filter.h
index 474fbf4591ab7fda7fdd58a5313bf55dc19310ed..70078fe94ccd4f88d0540e6087d39505e1084c0d 100644
--- a/ipc/ipc_forwarding_message_filter.h
+++ b/ipc/ipc_forwarding_message_filter.h
@@ -19,30 +19,32 @@ namespace IPC {
// This class can be used to intercept routed messages and
// deliver them to a different task runner than they would otherwise
// be sent. Messages are filtered based on type. To route these messages,
-// add a MessageRouter to the handler.
+// add a Handler to the filter.
//
-// The user of this class implements ForwardingMessageFilter::Client,
+// The user of this class implements ForwardingMessageFilter::Handler,
// which will receive the intercepted messages, on the specified target thread.
+// The caller must ensure that each handler in |multi_handlers_| outlives the
+// lifetime of the filter.
+// User can add multiple handlers for specific routing id. When messages are
+// arrived, all handlers in |multi_handlers_| for routing id will be executed.
class IPC_EXPORT ForwardingMessageFilter : public MessageFilter {
public:
// The handler is invoked on the thread associated with
- // |target_task_runner| with messages that were intercepted by this filter.
+ // |target_task_runner_| with messages that were intercepted by this filter.
typedef base::Callback<void(const Message&)> Handler;
// This filter will intercept |message_ids_to_filter| and post
// them to the provided |target_task_runner|, where they will be given
- // to |handler|.
- //
- // The caller must ensure that |handler| outlives the lifetime of the filter.
+ // to all handlers in the |multi_handlers_|.
ForwardingMessageFilter(
const uint32* message_ids_to_filter,
size_t num_message_ids_to_filter,
base::TaskRunner* target_task_runner);
- // Define the message routes to be filtered.
+ // Define the message handler to be filtered.
void AddRoute(int routing_id, const Handler& handler);
- void RemoveRoute(int routing_id);
+ void RemoveRoute(int routing_id, const Handler& handler);
// MessageFilter methods:
virtual bool OnMessageReceived(const Message& message) override;
@@ -52,15 +54,16 @@ class IPC_EXPORT ForwardingMessageFilter : public MessageFilter {
std::set<int> message_ids_to_filter_;
- // The handler_ only gets Run on the thread corresponding to
+ // The handler only gets run on the thread corresponding to
// target_task_runner_.
scoped_refptr<base::TaskRunner> target_task_runner_;
- // Protects access to routes_.
+ // Protects access to |multi_handlers_|.
base::Lock handlers_lock_;
- // Indicates the routing_ids for which messages should be filtered.
- std::map<int, Handler> handlers_;
+ // Maps the routing_id for which messages should be filtered and handlers
+ // which will be routed.
+ std::multimap<int, Handler> multi_handlers_;
DISALLOW_COPY_AND_ASSIGN(ForwardingMessageFilter);
};

Powered by Google App Engine
This is Rietveld 408576698