| Index: ppapi/host/ppapi_host.cc
|
| diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc
|
| index 87545019e1a88abc7927f3ffa54958487d8fc0f4..14a3a4f3860b4fe84933b81f9fa34b99ae6e7131 100644
|
| --- a/ppapi/host/ppapi_host.cc
|
| +++ b/ppapi/host/ppapi_host.cc
|
| @@ -8,6 +8,7 @@
|
| #include "ppapi/c/pp_errors.h"
|
| #include "ppapi/host/host_factory.h"
|
| #include "ppapi/host/host_message_context.h"
|
| +#include "ppapi/host/instance_message_filter.h"
|
| #include "ppapi/host/resource_host.h"
|
| #include "ppapi/proxy/ppapi_messages.h"
|
| #include "ppapi/proxy/resource_message_params.h"
|
| @@ -33,6 +34,10 @@ PpapiHost::PpapiHost(IPC::Sender* sender,
|
| }
|
|
|
| PpapiHost::~PpapiHost() {
|
| + // Delete these explicitly before destruction since then the host is still
|
| + // technically alive in case one of the filters accesses us from the
|
| + // destructor.
|
| + instance_message_filters_.clear();
|
| }
|
|
|
| bool PpapiHost::Send(IPC::Message* msg) {
|
| @@ -50,6 +55,16 @@ bool PpapiHost::OnMessageReceived(const IPC::Message& msg) {
|
| OnHostMsgResourceDestroyed)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| +
|
| + if (!handled) {
|
| + for (size_t i = 0; i < instance_message_filters_.size(); i++) {
|
| + if (instance_message_filters_[i]->OnInstanceMessageReceived(msg)) {
|
| + handled = true;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| return handled;
|
| }
|
|
|
| @@ -58,6 +73,12 @@ void PpapiHost::SendReply(const proxy::ResourceMessageReplyParams& params,
|
| Send(new PpapiPluginMsg_ResourceReply(params, msg));
|
| }
|
|
|
| +
|
| +void PpapiHost::AddInstanceMessageFilter(
|
| + scoped_ptr<InstanceMessageFilter> filter) {
|
| + instance_message_filters_.push_back(filter.release());
|
| +}
|
| +
|
| void PpapiHost::OnHostMsgResourceCall(
|
| const proxy::ResourceMessageCallParams& params,
|
| const IPC::Message& nested_msg) {
|
| @@ -100,8 +121,7 @@ void PpapiHost::OnHostMsgResourceCreated(
|
| return;
|
|
|
| scoped_ptr<ResourceHost> resource_host(
|
| - host_factory_->CreateResourceHost(this, params, instance,
|
| - nested_msg));
|
| + host_factory_->CreateResourceHost(this, params, instance, nested_msg));
|
| if (!resource_host.get()) {
|
| NOTREACHED();
|
| return;
|
|
|