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

Side by Side Diff: ppapi/host/resource_message_filter.cc

Issue 1174543002: ppapi: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix V8VarConverterTest. Created 5 years, 6 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 unified diff | 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 »
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/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
11 #include "base/thread_task_runner_handle.h"
11 #include "ipc/ipc_message.h" 12 #include "ipc/ipc_message.h"
12 #include "ppapi/c/pp_errors.h" 13 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/host/ppapi_host.h" 14 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/host/resource_host.h" 15 #include "ppapi/host/resource_host.h"
15 16
16 namespace ppapi { 17 namespace ppapi {
17 namespace host { 18 namespace host {
18 19
19 namespace internal { 20 namespace internal {
20 21
21 // static 22 // static
22 void ResourceMessageFilterDeleteTraits::Destruct( 23 void ResourceMessageFilterDeleteTraits::Destruct(
23 const ResourceMessageFilter* filter) { 24 const ResourceMessageFilter* filter) {
24 if (!filter->deletion_message_loop_proxy_->BelongsToCurrentThread()) { 25 if (!filter->deletion_task_runner_->BelongsToCurrentThread()) {
25 // During shutdown the object may not be deleted, but it should be okay to 26 // During shutdown the object may not be deleted, but it should be okay to
26 // leak in that case. 27 // leak in that case.
27 filter->deletion_message_loop_proxy_->DeleteSoon(FROM_HERE, filter); 28 filter->deletion_task_runner_->DeleteSoon(FROM_HERE, filter);
28 } else { 29 } else {
29 delete filter; 30 delete filter;
30 } 31 }
31 } 32 }
32 33
33 } // namespace internal 34 } // namespace internal
34 35
35 ResourceMessageFilter::ResourceMessageFilter() 36 ResourceMessageFilter::ResourceMessageFilter()
36 : deletion_message_loop_proxy_( 37 : deletion_task_runner_(base::ThreadTaskRunnerHandle::Get()),
37 base::MessageLoop::current()->message_loop_proxy()), 38 reply_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
38 reply_thread_message_loop_proxy_(
39 base::MessageLoop::current()->message_loop_proxy()),
40 resource_host_(NULL) { 39 resource_host_(NULL) {
41 } 40 }
42 41
43 ResourceMessageFilter::ResourceMessageFilter( 42 ResourceMessageFilter::ResourceMessageFilter(
44 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy) 43 scoped_refptr<base::SingleThreadTaskRunner> reply_thread_task_runner)
45 : deletion_message_loop_proxy_( 44 : deletion_task_runner_(base::ThreadTaskRunnerHandle::Get()),
46 base::MessageLoop::current()->message_loop_proxy()), 45 reply_thread_task_runner_(reply_thread_task_runner),
47 reply_thread_message_loop_proxy_(reply_thread_message_loop_proxy),
48 resource_host_(NULL) { 46 resource_host_(NULL) {
49 } 47 }
50 48
51 ResourceMessageFilter::~ResourceMessageFilter() { 49 ResourceMessageFilter::~ResourceMessageFilter() {
52 } 50 }
53 51
54 void ResourceMessageFilter::OnFilterAdded(ResourceHost* resource_host) { 52 void ResourceMessageFilter::OnFilterAdded(ResourceHost* resource_host) {
55 resource_host_ = resource_host; 53 resource_host_ = resource_host;
56 } 54 }
57 55
(...skipping 16 matching lines...) Expand all
74 &ResourceMessageFilter::DispatchMessage, this, msg, context_copy)); 72 &ResourceMessageFilter::DispatchMessage, this, msg, context_copy));
75 } 73 }
76 return true; 74 return true;
77 } 75 }
78 76
79 return false; 77 return false;
80 } 78 }
81 79
82 void ResourceMessageFilter::SendReply(const ReplyMessageContext& context, 80 void ResourceMessageFilter::SendReply(const ReplyMessageContext& context,
83 const IPC::Message& msg) { 81 const IPC::Message& msg) {
84 if (!reply_thread_message_loop_proxy_->BelongsToCurrentThread()) { 82 if (!reply_thread_task_runner_->BelongsToCurrentThread()) {
85 reply_thread_message_loop_proxy_->PostTask(FROM_HERE, 83 reply_thread_task_runner_->PostTask(
84 FROM_HERE,
86 base::Bind(&ResourceMessageFilter::SendReply, this, context, msg)); 85 base::Bind(&ResourceMessageFilter::SendReply, this, context, msg));
87 return; 86 return;
88 } 87 }
89 if (resource_host_) 88 if (resource_host_)
90 resource_host_->SendReply(context, msg); 89 resource_host_->SendReply(context, msg);
91 } 90 }
92 91
93 scoped_refptr<base::TaskRunner> 92 scoped_refptr<base::TaskRunner>
94 ResourceMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg) { 93 ResourceMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg) {
95 return NULL; 94 return NULL;
96 } 95 }
97 96
98 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg, 97 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg,
99 HostMessageContext context) { 98 HostMessageContext context) {
100 RunMessageHandlerAndReply(msg, &context); 99 RunMessageHandlerAndReply(msg, &context);
101 } 100 }
102 101
103 } // namespace host 102 } // namespace host
104 } // namespace ppapi 103 } // 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