Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_handler.h" | 5 #include "ppapi/proxy/message_handler.h" |
| 6 | 6 |
| 7 #include "base/location.h" | |
| 8 #include "base/single_thread_task_runner.h" | |
| 7 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 8 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
| 9 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 10 #include "ppapi/proxy/ppb_message_loop_proxy.h" | 12 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
| 11 #include "ppapi/shared_impl/proxy_lock.h" | 13 #include "ppapi/shared_impl/proxy_lock.h" |
| 12 #include "ppapi/shared_impl/scoped_pp_var.h" | 14 #include "ppapi/shared_impl/scoped_pp_var.h" |
| 13 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
| 14 | 16 |
| 15 namespace ppapi { | 17 namespace ppapi { |
| 16 namespace proxy { | 18 namespace proxy { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 *error = PP_OK; | 88 *error = PP_OK; |
| 87 return result.Pass(); | 89 return result.Pass(); |
| 88 } | 90 } |
| 89 | 91 |
| 90 MessageHandler::~MessageHandler() { | 92 MessageHandler::~MessageHandler() { |
| 91 // It's possible the message_loop_proxy is NULL if that loop has been quit. | 93 // It's possible the message_loop_proxy is NULL if that loop has been quit. |
| 92 // In that case, we unfortunately just can't call Destroy. | 94 // In that case, we unfortunately just can't call Destroy. |
| 93 if (message_loop_->message_loop_proxy().get()) { | 95 if (message_loop_->message_loop_proxy().get()) { |
| 94 // The posted task won't have the proxy lock, but that's OK, it doesn't | 96 // The posted task won't have the proxy lock, but that's OK, it doesn't |
| 95 // touch any internal state; it's a direct call on the plugin's function. | 97 // touch any internal state; it's a direct call on the plugin's function. |
| 96 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, | 98 message_loop_->message_loop_proxy()->PostTask( |
| 97 base::Bind(handler_if_->Destroy, | 99 FROM_HERE, base::Bind(handler_if_->Destroy, instance_, user_data_)); |
| 98 instance_, | |
| 99 user_data_)); | |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool MessageHandler::LoopIsValid() const { | 103 bool MessageHandler::LoopIsValid() const { |
| 104 return !!message_loop_->message_loop_proxy().get(); | 104 return !!message_loop_->message_loop_proxy().get(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void MessageHandler::HandleMessage(ScopedPPVar var) { | 107 void MessageHandler::HandleMessage(ScopedPPVar var) { |
| 108 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, | 108 message_loop_->message_loop_proxy()->PostTask( |
| 109 RunWhileLocked(base::Bind(&HandleMessageWrapper, | 109 FROM_HERE, RunWhileLocked(base::Bind(&HandleMessageWrapper, |
| 110 handler_if_->HandleMessage, | 110 handler_if_->HandleMessage, |
| 111 instance_, | 111 instance_, user_data_, var))); |
| 112 user_data_, | |
| 113 var))); | |
| 114 } | 112 } |
| 115 | 113 |
| 116 void MessageHandler::HandleBlockingMessage(ScopedPPVar var, | 114 void MessageHandler::HandleBlockingMessage(ScopedPPVar var, |
| 117 scoped_ptr<IPC::Message> reply_msg) { | 115 scoped_ptr<IPC::Message> reply_msg) { |
| 118 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, | 116 message_loop_->message_loop_proxy()->PostTask( |
|
bbudge
2015/06/10 20:57:46
Looks like this was missed.
Sami
2015/06/11 18:03:46
message_loop_ is a MessageLoopResource, not a base
| |
| 119 RunWhileLocked(base::Bind(&HandleBlockingMessageWrapper, | 117 FROM_HERE, |
| 120 handler_if_->HandleBlockingMessage, | 118 RunWhileLocked(base::Bind( |
| 121 instance_, | 119 &HandleBlockingMessageWrapper, handler_if_->HandleBlockingMessage, |
| 122 user_data_, | 120 instance_, user_data_, var, base::Passed(reply_msg.Pass())))); |
| 123 var, | |
| 124 base::Passed(reply_msg.Pass())))); | |
| 125 } | 121 } |
| 126 | 122 |
| 127 MessageHandler::MessageHandler( | 123 MessageHandler::MessageHandler( |
| 128 PP_Instance instance, | 124 PP_Instance instance, |
| 129 const PPP_MessageHandler_0_2* handler_if, | 125 const PPP_MessageHandler_0_2* handler_if, |
| 130 void* user_data, | 126 void* user_data, |
| 131 scoped_refptr<MessageLoopResource> message_loop) | 127 scoped_refptr<MessageLoopResource> message_loop) |
| 132 : instance_(instance), | 128 : instance_(instance), |
| 133 handler_if_(handler_if), | 129 handler_if_(handler_if), |
| 134 user_data_(user_data), | 130 user_data_(user_data), |
| 135 message_loop_(message_loop) { | 131 message_loop_(message_loop) { |
| 136 } | 132 } |
| 137 | 133 |
| 138 } // namespace proxy | 134 } // namespace proxy |
| 139 } // namespace ppapi | 135 } // namespace ppapi |
| OLD | NEW |