diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 00:07:30 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 00:07:30 +0000 |
commit | 7412204291319c7099206d8e4964b981737e2170 (patch) | |
tree | e96de76e7864b31e664b5a902b2e3f4959d86843 /ipc/message_filter.h | |
parent | a8f2a3efb04eea886d198c2dcc87bed6cf472dd6 (diff) | |
download | chromium_src-7412204291319c7099206d8e4964b981737e2170.zip chromium_src-7412204291319c7099206d8e4964b981737e2170.tar.gz chromium_src-7412204291319c7099206d8e4964b981737e2170.tar.bz2 |
Move IPC::MessageFilter and router to a separate file
There are no changes in implementation in this CL. This is in preparation
for making IPC::Channel support filters on the Channel's thread.
BUG=364241
TBR=cpu@chromium.org,nduca@chromium.org
cpu: OWNERS for win8
nduca: OWNERS for components/tracing
Review URL: https://codereview.chromium.org/245443005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/message_filter.h')
-rw-r--r-- | ipc/message_filter.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/ipc/message_filter.h b/ipc/message_filter.h new file mode 100644 index 0000000..0371585 --- /dev/null +++ b/ipc/message_filter.h @@ -0,0 +1,67 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IPC_MESSAGE_FILTER_H_ +#define IPC_MESSAGE_FILTER_H_ + +#include <vector> + +#include "base/memory/ref_counted.h" +#include "ipc/ipc_export.h" + +namespace IPC { + +class Channel; +class Message; + +// A class that receives messages on the thread where the IPC channel is +// running. It can choose to prevent the default action for an IPC message. +class IPC_EXPORT MessageFilter + : public base::RefCountedThreadSafe<MessageFilter> { + public: + MessageFilter(); + + // Called on the background thread to provide the filter with access to the + // channel. Called when the IPC channel is initialized or when AddFilter + // is called if the channel is already initialized. + virtual void OnFilterAdded(Channel* channel); + + // Called on the background thread when the filter has been removed from + // the ChannelProxy and when the Channel is closing. After a filter is + // removed, it will not be called again. + virtual void OnFilterRemoved(); + + // Called to inform the filter that the IPC channel is connected and we + // have received the internal Hello message from the peer. + virtual void OnChannelConnected(int32 peer_pid); + + // Called when there is an error on the channel, typically that the channel + // has been closed. + virtual void OnChannelError(); + + // Called to inform the filter that the IPC channel will be destroyed. + // OnFilterRemoved is called immediately after this. + virtual void OnChannelClosing(); + + // Return true to indicate that the message was handled, or false to let + // the message be handled in the default way. + virtual bool OnMessageReceived(const Message& message); + + // Called to query the Message classes supported by the filter. Return + // false to indicate that all message types should reach the filter, or true + // if the resulting contents of |supported_message_classes| may be used to + // selectively offer messages of a particular class to the filter. + virtual bool GetSupportedMessageClasses( + std::vector<uint32>* supported_message_classes) const; + + protected: + virtual ~MessageFilter(); + + private: + friend class base::RefCountedThreadSafe<MessageFilter>; +}; + +} // namespace IPC + +#endif // IPC_MESSAGE_FILTER_H_ |