OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 PPAPI_PROXY_PLUGIN_MESSAGE_FILTER_H_ |
| 6 #define PPAPI_PROXY_PLUGIN_MESSAGE_FILTER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "ipc/ipc_channel_proxy.h" |
| 11 #include "ipc/ipc_message.h" |
| 12 #include "ppapi/c/pp_instance.h" |
| 13 |
| 14 namespace pp { |
| 15 namespace proxy { |
| 16 |
| 17 // Listens for messages on the I/O thread of the plugin and handles some of |
| 18 // them to avoid needing to block on the plugin. |
| 19 // |
| 20 // There is one instance of this class for each renderer channel (same as for |
| 21 // the PluginDispatchers). |
| 22 class PluginMessageFilter : public IPC::ChannelProxy::MessageFilter, |
| 23 public IPC::Message::Sender { |
| 24 public: |
| 25 // The input is a pointer to a set that will be used to uniquify PP_Instances |
| 26 // across all renderer channels. The same pointer should be passed to each |
| 27 // MessageFilter to ensure uniqueness, and the value should outlive this |
| 28 // class. |
| 29 PluginMessageFilter(std::set<PP_Instance>* seen_instance_ids); |
| 30 virtual ~PluginMessageFilter(); |
| 31 |
| 32 // MessageFilter implementation. |
| 33 virtual void OnFilterAdded(IPC::Channel* channel); |
| 34 virtual void OnFilterRemoved(); |
| 35 virtual bool OnMessageReceived(const IPC::Message& message); |
| 36 |
| 37 // Message::Sender implementation. |
| 38 virtual bool Send(IPC::Message* msg); |
| 39 |
| 40 private: |
| 41 void OnMsgReserveInstanceId(PP_Instance instance, bool* usable); |
| 42 |
| 43 // All instance IDs every queried by any renderer on this plugin. This is |
| 44 // used to make sure that new instance IDs are unique. This is a non-owning |
| 45 // pointer, it will be managed by the later that creates this class. |
| 46 std::set<PP_Instance>* seen_instance_ids_; |
| 47 |
| 48 // The IPC channel to the renderer. May be NULL if we're not currently |
| 49 // attached as a filter. |
| 50 IPC::Channel* channel_; |
| 51 }; |
| 52 |
| 53 } // namespace proxy |
| 54 } // namespace pp |
| 55 |
| 56 #endif // PPAPI_PROXY_PLUGIN_MESSAGE_FILTER_H_ |
OLD | NEW |