| Index: ipc/ipc_forwarding_message_filter.h
|
| diff --git a/ipc/ipc_forwarding_message_filter.h b/ipc/ipc_forwarding_message_filter.h
|
| index 919a44d75994588f222f6136077a4f14ac7a972b..fe850522b09883788d7272934becd5ef9dd5f6fa 100644
|
| --- a/ipc/ipc_forwarding_message_filter.h
|
| +++ b/ipc/ipc_forwarding_message_filter.h
|
| @@ -30,6 +30,8 @@ class IPC_EXPORT ForwardingMessageFilter : public ChannelProxy::MessageFilter {
|
| // |target_task_runner| with messages that were intercepted by this filter.
|
| typedef base::Callback<void(const Message&)> Handler;
|
|
|
| + typedef base::Callback<int(const Message&)> IDCallback;
|
| +
|
| // This filter will intercept |message_ids_to_filter| and post
|
| // them to the provided |target_task_runner|, where they will be given
|
| // to |handler|.
|
| @@ -40,13 +42,23 @@ class IPC_EXPORT ForwardingMessageFilter : public ChannelProxy::MessageFilter {
|
| size_t num_message_ids_to_filter,
|
| base::TaskRunner* target_task_runner);
|
|
|
| - // Define the message routes to be filtered.
|
| + // Define the message IDs to be filtered. By default, the ID is the message's
|
| + // routing ID but this can be changed with SetIDCallback.
|
| void AddRoute(int routing_id, const Handler& handler);
|
| void RemoveRoute(int routing_id);
|
|
|
| + // Set the function used to extract an ID from a message.
|
| + void SetIDCallback(const IDCallback& function);
|
| +
|
| // ChannelProxy::MessageFilter methods:
|
| virtual bool OnMessageReceived(const Message& message) OVERRIDE;
|
|
|
| + // Extract the routing ID. Can be used to reset the ID function to the
|
| + // default.
|
| + static int GetMessageRoutingID(const Message& message) {
|
| + return message.routing_id();
|
| + }
|
| +
|
| private:
|
| friend class ChannelProxy::MessageFilter;
|
| virtual ~ForwardingMessageFilter();
|
| @@ -63,6 +75,9 @@ class IPC_EXPORT ForwardingMessageFilter : public ChannelProxy::MessageFilter {
|
| // Indicates the routing_ids for which messages should be filtered.
|
| std::map<int, Handler> handlers_;
|
|
|
| + // The function used for extracting IDs.
|
| + IDCallback id_callback_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(ForwardingMessageFilter);
|
| };
|
|
|
|
|