| OLD | NEW |
| 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/message_loop/message_loop_proxy.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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 void ResourceReplyThreadRegistrar::HandleOnIOThread(uint32 nested_msg_type) { | |
| 54 base::AutoLock auto_lock(lock_); | |
| 55 io_thread_message_types_.insert(nested_msg_type); | |
| 56 } | |
| 57 | |
| 58 scoped_refptr<base::MessageLoopProxy> | 53 scoped_refptr<base::MessageLoopProxy> |
| 59 ResourceReplyThreadRegistrar::GetTargetThread( | 54 ResourceReplyThreadRegistrar::GetTargetThread( |
| 60 const ResourceMessageReplyParams& reply_params, | 55 const ResourceMessageReplyParams& reply_params, |
| 61 const IPC::Message& nested_msg) { | 56 const IPC::Message& nested_msg) { |
| 62 base::AutoLock auto_lock(lock_); | 57 base::AutoLock auto_lock(lock_); |
| 63 ResourceMap::iterator resource_iter = map_.find(reply_params.pp_resource()); | 58 ResourceMap::iterator resource_iter = map_.find(reply_params.pp_resource()); |
| 64 if (resource_iter != map_.end()) { | 59 if (resource_iter != map_.end()) { |
| 65 SequenceThreadMap::iterator sequence_thread_iter = | 60 SequenceThreadMap::iterator sequence_thread_iter = |
| 66 resource_iter->second.find(reply_params.sequence()); | 61 resource_iter->second.find(reply_params.sequence()); |
| 67 if (sequence_thread_iter != resource_iter->second.end()) { | 62 if (sequence_thread_iter != resource_iter->second.end()) { |
| 68 scoped_refptr<base::MessageLoopProxy> target = | 63 scoped_refptr<base::MessageLoopProxy> target = |
| 69 sequence_thread_iter->second; | 64 sequence_thread_iter->second; |
| 70 resource_iter->second.erase(sequence_thread_iter); | 65 resource_iter->second.erase(sequence_thread_iter); |
| 71 return target; | 66 return target; |
| 72 } | 67 } |
| 73 } | 68 } |
| 74 | 69 |
| 75 if (io_thread_message_types_.count(nested_msg.type()) != 0) | |
| 76 return scoped_refptr<base::MessageLoopProxy>(); | |
| 77 | |
| 78 return main_thread_; | 70 return main_thread_; |
| 79 } | 71 } |
| 80 | 72 |
| 81 } // namespace proxy | 73 } // namespace proxy |
| 82 } // namespace ppapi | 74 } // namespace ppapi |
| OLD | NEW |