Chromium Code Reviews| Index: ppapi/host/resource_message_filter.cc |
| diff --git a/ppapi/host/resource_message_filter.cc b/ppapi/host/resource_message_filter.cc |
| index ff56cac8c46279759d9b207bb1205a502faf2034..f6677617bf54ca82766e77ae464a84458a15288c 100644 |
| --- a/ppapi/host/resource_message_filter.cc |
| +++ b/ppapi/host/resource_message_filter.cc |
| @@ -16,14 +16,32 @@ |
| namespace ppapi { |
| namespace host { |
| -ResourceMessageFilter::ResourceMessageFilter() |
| - : reply_thread_message_loop_proxy_( |
| +namespace internal { |
| + |
| +// static |
| +void ResourceMessageFilterDeleteTraits::Destruct( |
| + const ResourceMessageFilter* filter) { |
| + filter->InternalDestruct(); |
| +} |
| + |
| +} // namespace internal |
| + |
| +ResourceMessageFilter::ResourceMessageFilter(DeletionThread deletion_thread) |
| + : deletion_message_loop_proxy_( |
| + deletion_thread == DELETE_ON_CREATION_THREAD ? |
| + base::MessageLoop::current()->message_loop_proxy() : NULL), |
| + reply_thread_message_loop_proxy_( |
| base::MessageLoop::current()->message_loop_proxy()), |
| - resource_host_(NULL) {} |
| + resource_host_(NULL) { |
| +} |
| ResourceMessageFilter::ResourceMessageFilter( |
| + DeletionThread deletion_thread, |
| scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy) |
| - : reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy), |
| + : deletion_message_loop_proxy_( |
| + deletion_thread == DELETE_ON_CREATION_THREAD ? |
| + base::MessageLoop::current()->message_loop_proxy() : NULL), |
| + reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy), |
| resource_host_(NULL) { |
| } |
| @@ -79,5 +97,16 @@ void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg, |
| RunMessageHandlerAndReply(msg, &context); |
| } |
| +void ResourceMessageFilter::InternalDestruct() const { |
| + if (deletion_message_loop_proxy_ && |
| + !deletion_message_loop_proxy_->BelongsToCurrentThread()) { |
| + // During shutdown the object may not be deleted, but it should be okay to |
| + // leak in that case. |
| + deletion_message_loop_proxy_->DeleteSoon(FROM_HERE, this); |
|
dmichael (off chromium)
2013/10/30 22:05:42
Would there be any harm in just always deleting it
yzshen1
2013/10/30 22:11:55
It is not harmful for all the existing message fil
dmichael (off chromium)
2013/10/31 16:14:59
I see what you mean, but I would lean in favor of
yzshen1
2013/10/31 21:28:04
Yeah. Sounds good. I have made the change.
|
| + } else { |
| + delete this; |
| + } |
| +} |
| + |
| } // namespace host |
| } // namespace ppapi |