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