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

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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (!filter->deletion_message_loop_proxy_->BelongsToCurrentThread()) {
25 // During shutdown the object may not be deleted, but it should be okay to
26 // leak in that case.
27 filter->deletion_message_loop_proxy_->DeleteSoon(FROM_HERE, filter);
28 } else {
29 delete filter;
30 }
31 }
32
33 } // namespace internal
34
19 ResourceMessageFilter::ResourceMessageFilter() 35 ResourceMessageFilter::ResourceMessageFilter()
20 : reply_thread_message_loop_proxy_( 36 : deletion_message_loop_proxy_(
21 base::MessageLoop::current()->message_loop_proxy()), 37 base::MessageLoop::current()->message_loop_proxy()),
22 resource_host_(NULL) {} 38 reply_thread_message_loop_proxy_(
39 base::MessageLoop::current()->message_loop_proxy()),
40 resource_host_(NULL) {
41 }
23 42
24 ResourceMessageFilter::ResourceMessageFilter( 43 ResourceMessageFilter::ResourceMessageFilter(
25 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy) 44 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy)
26 : reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy), 45 : deletion_message_loop_proxy_(
46 base::MessageLoop::current()->message_loop_proxy()),
47 reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy),
27 resource_host_(NULL) { 48 resource_host_(NULL) {
28 } 49 }
29 50
30 ResourceMessageFilter::~ResourceMessageFilter() { 51 ResourceMessageFilter::~ResourceMessageFilter() {
31 } 52 }
32 53
33 void ResourceMessageFilter::OnFilterAdded(ResourceHost* resource_host) { 54 void ResourceMessageFilter::OnFilterAdded(ResourceHost* resource_host) {
34 resource_host_ = resource_host; 55 resource_host_ = resource_host;
35 } 56 }
36 57
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return NULL; 95 return NULL;
75 } 96 }
76 97
77 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg, 98 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg,
78 HostMessageContext context) { 99 HostMessageContext context) {
79 RunMessageHandlerAndReply(msg, &context); 100 RunMessageHandlerAndReply(msg, &context);
80 } 101 }
81 102
82 } // namespace host 103 } // namespace host
83 } // namespace ppapi 104 } // namespace ppapi
OLDNEW
« 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