Chromium Code Reviews| Index: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h |
| =================================================================== |
| --- content/browser/renderer_host/pepper/browser_ppapi_host_impl.h (revision 166155) |
| +++ content/browser/renderer_host/pepper/browser_ppapi_host_impl.h (working copy) |
| @@ -15,25 +15,17 @@ |
| #include "ipc/ipc_channel_proxy.h" |
| #include "ppapi/host/ppapi_host.h" |
| -namespace IPC { |
| -class Sender; |
| -} |
| - |
| namespace content { |
| -class CONTENT_EXPORT BrowserPpapiHostImpl |
| - : public BrowserPpapiHost, |
| - public IPC::ChannelProxy::MessageFilter { |
| +class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { |
| public: |
| // The creator is responsible for calling set_plugin_process_handle as soon |
| // as it is known (we start the process asynchronously so it won't be known |
| // when this object is created). |
| BrowserPpapiHostImpl(IPC::Sender* sender, |
| const ppapi::PpapiPermissions& permissions); |
| + virtual ~BrowserPpapiHostImpl(); |
| - // IPC::ChannelProxy::MessageFilter. |
| - virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| - |
| // BrowserPpapiHost. |
| virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; |
| virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; |
| @@ -54,6 +46,10 @@ |
| int render_view_id); |
| void DeleteInstanceForView(PP_Instance instance); |
| + scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() { |
| + return message_filter_; |
| + } |
| + |
| private: |
| friend class BrowserPpapiHostTest; |
| @@ -63,8 +59,22 @@ |
| }; |
| typedef std::map<PP_Instance, RenderViewIDs> InstanceToViewMap; |
| - virtual ~BrowserPpapiHostImpl(); |
| + // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted, |
| + // preventing us from returning these to embedders without holding a |
| + // reference. To avoid that, define a message filter object. |
| + class HostMessageFilter : public IPC::ChannelProxy::MessageFilter { |
| + public: |
| + explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host) |
| + : ppapi_host_(ppapi_host) {} |
| + // IPC::ChannelProxy::MessageFilter. |
| + virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| + private: |
| + virtual ~HostMessageFilter() {} |
| + |
| + ppapi::host::PpapiHost* ppapi_host_; |
|
brettw
2012/11/07 00:18:11
You should have a way for this back pointer to be
bbudge
2012/11/07 00:51:46
Good catch. Done.
|
| + }; |
| + |
| ppapi::host::PpapiHost ppapi_host_; |
| base::ProcessHandle plugin_process_handle_; |
| @@ -72,6 +82,8 @@ |
| // RenderProcess/RenderView IDs. |
| InstanceToViewMap instance_to_view_; |
| + scoped_refptr<HostMessageFilter> message_filter_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); |
| }; |