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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ppapi/host/resource_message_filter.h" 5 #include "ppapi/host/resource_message_filter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
11 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/host/ppapi_host.h" 13 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/host/resource_host.h" 14 #include "ppapi/host/resource_host.h"
15 15
16 namespace ppapi { 16 namespace ppapi {
17 namespace host { 17 namespace host {
18 18
19 namespace internal {
20
21 // static
22 void ResourceMessageFilterDeleteTraits::Destruct(
23 const ResourceMessageFilter* filter) {
24 filter->InternalDestruct();
25 }
26
27 } // namespace internal
28
19 ResourceMessageFilter::ResourceMessageFilter() 29 ResourceMessageFilter::ResourceMessageFilter()
20 : reply_thread_message_loop_proxy_( 30 : deletion_message_loop_proxy_(
21 base::MessageLoop::current()->message_loop_proxy()), 31 base::MessageLoop::current()->message_loop_proxy()),
22 resource_host_(NULL) {} 32 reply_thread_message_loop_proxy_(
33 base::MessageLoop::current()->message_loop_proxy()),
34 resource_host_(NULL) {
35 }
23 36
24 ResourceMessageFilter::ResourceMessageFilter( 37 ResourceMessageFilter::ResourceMessageFilter(
25 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy) 38 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy)
26 : reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy), 39 : deletion_message_loop_proxy_(
40 base::MessageLoop::current()->message_loop_proxy()),
41 reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy),
27 resource_host_(NULL) { 42 resource_host_(NULL) {
28 } 43 }
29 44
30 ResourceMessageFilter::~ResourceMessageFilter() { 45 ResourceMessageFilter::~ResourceMessageFilter() {
31 } 46 }
32 47
33 void ResourceMessageFilter::OnFilterAdded(ResourceHost* resource_host) { 48 void ResourceMessageFilter::OnFilterAdded(ResourceHost* resource_host) {
34 resource_host_ = resource_host; 49 resource_host_ = resource_host;
35 } 50 }
36 51
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 scoped_refptr<base::TaskRunner> 87 scoped_refptr<base::TaskRunner>
73 ResourceMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg) { 88 ResourceMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg) {
74 return NULL; 89 return NULL;
75 } 90 }
76 91
77 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg, 92 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg,
78 HostMessageContext context) { 93 HostMessageContext context) {
79 RunMessageHandlerAndReply(msg, &context); 94 RunMessageHandlerAndReply(msg, &context);
80 } 95 }
81 96
97 void ResourceMessageFilter::InternalDestruct() const {
98 if (!deletion_message_loop_proxy_->BelongsToCurrentThread()) {
99 // During shutdown the object may not be deleted, but it should be okay to
100 // leak in that case.
101 deletion_message_loop_proxy_->DeleteSoon(FROM_HERE, this);
102 } else {
103 delete this;
104 }
105 }
106
82 } // namespace host 107 } // namespace host
83 } // namespace ppapi 108 } // namespace ppapi
OLDNEW
« ppapi/host/resource_message_filter.h ('K') | « ppapi/host/resource_message_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698