message_filter_router.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2014 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. #ifndef IPC_MESSAGE_FILTER_ROUTER_H_
  5. #define IPC_MESSAGE_FILTER_ROUTER_H_
  6. #include <vector>
  7. #include "ipc/ipc_message_start.h"
  8. namespace IPC {
  9. class Message;
  10. class MessageFilter;
  11. class MessageFilterRouter {
  12. public:
  13. typedef std::vector<MessageFilter*> MessageFilters;
  14. MessageFilterRouter();
  15. ~MessageFilterRouter();
  16. void AddFilter(MessageFilter* filter);
  17. void RemoveFilter(MessageFilter* filter);
  18. bool TryFilters(const Message& message);
  19. void Clear();
  20. private:
  21. // List of global and selective filters; a given filter will exist in either
  22. // |message_global_filters_| OR |message_class_filters_|, but not both.
  23. // Note that |message_global_filters_| will be given first offering of any
  24. // given message. It's the filter implementer and installer's
  25. // responsibility to ensure that a filter is either global or selective to
  26. // ensure proper message filtering order.
  27. MessageFilters global_filters_;
  28. MessageFilters message_class_filters_[LastIPCMsgStart];
  29. };
  30. } // namespace IPC
  31. #endif // IPC_MESSAGE_FILTER_ROUTER_H_