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

Side by Side Diff: ppapi/proxy/resource_reply_thread_registrar.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/proxy/resource_reply_thread_registrar.h ('k') | ppapi/proxy/tracked_callback_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/proxy/resource_reply_thread_registrar.h" 5 #include "ppapi/proxy/resource_reply_thread_registrar.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/single_thread_task_runner.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ppapi/proxy/resource_message_params.h" 10 #include "ppapi/proxy/resource_message_params.h"
11 #include "ppapi/shared_impl/proxy_lock.h" 11 #include "ppapi/shared_impl/proxy_lock.h"
12 #include "ppapi/shared_impl/tracked_callback.h" 12 #include "ppapi/shared_impl/tracked_callback.h"
13 13
14 namespace ppapi { 14 namespace ppapi {
15 namespace proxy { 15 namespace proxy {
16 16
17 ResourceReplyThreadRegistrar::ResourceReplyThreadRegistrar( 17 ResourceReplyThreadRegistrar::ResourceReplyThreadRegistrar(
18 scoped_refptr<base::MessageLoopProxy> main_thread) 18 scoped_refptr<base::SingleThreadTaskRunner> main_thread)
19 : main_thread_(main_thread) { 19 : main_thread_(main_thread) {
20 } 20 }
21 21
22 ResourceReplyThreadRegistrar::~ResourceReplyThreadRegistrar() { 22 ResourceReplyThreadRegistrar::~ResourceReplyThreadRegistrar() {
23 } 23 }
24 24
25 void ResourceReplyThreadRegistrar::Register( 25 void ResourceReplyThreadRegistrar::Register(
26 PP_Resource resource, 26 PP_Resource resource,
27 int32_t sequence_number, 27 int32_t sequence_number,
28 scoped_refptr<TrackedCallback> reply_thread_hint) { 28 scoped_refptr<TrackedCallback> reply_thread_hint) {
29 ProxyLock::AssertAcquiredDebugOnly(); 29 ProxyLock::AssertAcquiredDebugOnly();
30 30
31 // Use the main thread if |reply_thread_hint| is NULL or blocking. 31 // Use the main thread if |reply_thread_hint| is NULL or blocking.
32 if (!reply_thread_hint.get() || reply_thread_hint->is_blocking()) 32 if (!reply_thread_hint.get() || reply_thread_hint->is_blocking())
33 return; 33 return;
34 34
35 DCHECK(reply_thread_hint->target_loop()); 35 DCHECK(reply_thread_hint->target_loop());
36 scoped_refptr<base::MessageLoopProxy> reply_thread( 36 scoped_refptr<base::SingleThreadTaskRunner> reply_thread(
37 reply_thread_hint->target_loop()->GetMessageLoopProxy()); 37 reply_thread_hint->target_loop()->GetTaskRunner());
38 { 38 {
39 base::AutoLock auto_lock(lock_); 39 base::AutoLock auto_lock(lock_);
40 40
41 if (reply_thread.get() == main_thread_.get()) 41 if (reply_thread.get() == main_thread_.get())
42 return; 42 return;
43 43
44 map_[resource][sequence_number] = reply_thread; 44 map_[resource][sequence_number] = reply_thread;
45 } 45 }
46 } 46 }
47 47
48 void ResourceReplyThreadRegistrar::Unregister(PP_Resource resource) { 48 void ResourceReplyThreadRegistrar::Unregister(PP_Resource resource) {
49 base::AutoLock auto_lock(lock_); 49 base::AutoLock auto_lock(lock_);
50 map_.erase(resource); 50 map_.erase(resource);
51 } 51 }
52 52
53 scoped_refptr<base::MessageLoopProxy> 53 scoped_refptr<base::SingleThreadTaskRunner>
54 ResourceReplyThreadRegistrar::GetTargetThread( 54 ResourceReplyThreadRegistrar::GetTargetThread(
55 const ResourceMessageReplyParams& reply_params, 55 const ResourceMessageReplyParams& reply_params,
56 const IPC::Message& nested_msg) { 56 const IPC::Message& nested_msg) {
57 base::AutoLock auto_lock(lock_); 57 base::AutoLock auto_lock(lock_);
58 ResourceMap::iterator resource_iter = map_.find(reply_params.pp_resource()); 58 ResourceMap::iterator resource_iter = map_.find(reply_params.pp_resource());
59 if (resource_iter != map_.end()) { 59 if (resource_iter != map_.end()) {
60 SequenceThreadMap::iterator sequence_thread_iter = 60 SequenceThreadMap::iterator sequence_thread_iter =
61 resource_iter->second.find(reply_params.sequence()); 61 resource_iter->second.find(reply_params.sequence());
62 if (sequence_thread_iter != resource_iter->second.end()) { 62 if (sequence_thread_iter != resource_iter->second.end()) {
63 scoped_refptr<base::MessageLoopProxy> target = 63 scoped_refptr<base::SingleThreadTaskRunner> target =
64 sequence_thread_iter->second; 64 sequence_thread_iter->second;
65 resource_iter->second.erase(sequence_thread_iter); 65 resource_iter->second.erase(sequence_thread_iter);
66 return target; 66 return target;
67 } 67 }
68 } 68 }
69 69
70 return main_thread_; 70 return main_thread_;
71 } 71 }
72 72
73 } // namespace proxy 73 } // namespace proxy
74 } // namespace ppapi 74 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/resource_reply_thread_registrar.h ('k') | ppapi/proxy/tracked_callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698