| 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 "ipc/ipc_message.h" | 7 #include "ipc/ipc_message.h" |
| 8 #include "ppapi/proxy/plugin_dispatcher.h" | 8 #include "ppapi/proxy/plugin_dispatcher.h" |
| 9 #include "ppapi/proxy/ppapi_messages.h" | 9 #include "ppapi/proxy/ppapi_messages.h" |
| 10 #include "ppapi/proxy/ppb_message_loop_proxy.h" | 10 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 result.reset(new MessageHandler( | 79 result.reset(new MessageHandler( |
| 80 instance, handler_if, user_data, message_loop_resource)); | 80 instance, handler_if, user_data, message_loop_resource)); |
| 81 *error = PP_OK; | 81 *error = PP_OK; |
| 82 return result.Pass(); | 82 return result.Pass(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 MessageHandler::~MessageHandler() { | 85 MessageHandler::~MessageHandler() { |
| 86 // It's possible the message_loop_proxy is NULL if that loop has been quit. | 86 // It's possible the message_loop_proxy is NULL if that loop has been quit. |
| 87 // In that case, we unfortunately just can't call Destroy. | 87 // In that case, we unfortunately just can't call Destroy. |
| 88 if (message_loop_->message_loop_proxy()) { | 88 if (message_loop_->message_loop_proxy().get()) { |
| 89 // The posted task won't have the proxy lock, but that's OK, it doesn't | 89 // The posted task won't have the proxy lock, but that's OK, it doesn't |
| 90 // touch any internal state; it's a direct call on the plugin's function. | 90 // touch any internal state; it's a direct call on the plugin's function. |
| 91 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, | 91 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, |
| 92 base::Bind(handler_if_->Destroy, | 92 base::Bind(handler_if_->Destroy, |
| 93 instance_, | 93 instance_, |
| 94 user_data_)); | 94 user_data_)); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool MessageHandler::LoopIsValid() const { | 98 bool MessageHandler::LoopIsValid() const { |
| 99 return !!message_loop_->message_loop_proxy(); | 99 return !!message_loop_->message_loop_proxy().get(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void MessageHandler::HandleMessage(ScopedPPVar var) { | 102 void MessageHandler::HandleMessage(ScopedPPVar var) { |
| 103 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, | 103 message_loop_->message_loop_proxy()->PostTask(FROM_HERE, |
| 104 RunWhileLocked(base::Bind(&HandleMessageWrapper, | 104 RunWhileLocked(base::Bind(&HandleMessageWrapper, |
| 105 handler_if_->HandleMessage, | 105 handler_if_->HandleMessage, |
| 106 instance_, | 106 instance_, |
| 107 user_data_, | 107 user_data_, |
| 108 var))); | 108 var))); |
| 109 } | 109 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 125 void* user_data, | 125 void* user_data, |
| 126 scoped_refptr<MessageLoopResource> message_loop) | 126 scoped_refptr<MessageLoopResource> message_loop) |
| 127 : instance_(instance), | 127 : instance_(instance), |
| 128 handler_if_(handler_if), | 128 handler_if_(handler_if), |
| 129 user_data_(user_data), | 129 user_data_(user_data), |
| 130 message_loop_(message_loop) { | 130 message_loop_(message_loop) { |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace proxy | 133 } // namespace proxy |
| 134 } // namespace ppapi | 134 } // namespace ppapi |
| OLD | NEW |