Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: ppapi/host/resource_message_filter.cc

Issue 53153002: Pepper: always delete ResourceMessageFilter objects on the creation thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/host/resource_message_filter.h ('k') | ppapi/host/resource_message_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ppapi/host/resource_message_filter.h ('k') | ppapi/host/resource_message_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698