OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/host_dispatcher.h" | 5 #include "ppapi/proxy/host_dispatcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 bool HostDispatcher::IsPlugin() const { | 129 bool HostDispatcher::IsPlugin() const { |
130 return false; | 130 return false; |
131 } | 131 } |
132 | 132 |
133 bool HostDispatcher::Send(IPC::Message* msg) { | 133 bool HostDispatcher::Send(IPC::Message* msg) { |
134 TRACE_EVENT2("ppapi proxy", "HostDispatcher::Send", | 134 TRACE_EVENT2("ppapi proxy", "HostDispatcher::Send", |
135 "Class", IPC_MESSAGE_ID_CLASS(msg->type()), | 135 "Class", IPC_MESSAGE_ID_CLASS(msg->type()), |
136 "Line", IPC_MESSAGE_ID_LINE(msg->type())); | 136 "Line", IPC_MESSAGE_ID_LINE(msg->type())); |
137 // Normal sync messages are set to unblock, which would normally cause the | 137 // Prevent the dispatcher from going away during the call. Scenarios |
138 // plugin to be reentered to process them. We only want to do this when we | 138 // where this could happen include a Send for a sync message which while |
139 // know the plugin is in a state to accept reentrancy. Since the plugin side | 139 // waiting for the reply, dispatches an incoming ExecuteScript call which |
140 // never clears this flag on messages it sends, we can't get deadlock, but we | 140 // destroys the plugin module and in turn the dispatcher, |
141 // may still get reentrancy in the host as a result. | 141 ScopedModuleReference ref(this); |
| 142 |
142 if (!allow_plugin_reentrancy_) | 143 if (!allow_plugin_reentrancy_) |
143 msg->set_unblock(false); | 144 msg->set_unblock(false); |
144 return Dispatcher::Send(msg); | 145 return Dispatcher::Send(msg); |
145 } | 146 } |
146 | 147 |
147 bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { | 148 bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { |
148 TRACE_EVENT2("ppapi proxy", "HostDispatcher::OnMessageReceived", | 149 TRACE_EVENT2("ppapi proxy", "HostDispatcher::OnMessageReceived", |
149 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), | 150 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), |
150 "Line", IPC_MESSAGE_ID_LINE(msg.type())); | 151 "Line", IPC_MESSAGE_ID_LINE(msg.type())); |
151 // We only want to allow reentrancy when the most recent message from the | 152 // We only want to allow reentrancy when the most recent message from the |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 dispatcher_ = static_cast<HostDispatcher*>(dispatcher); | 206 dispatcher_ = static_cast<HostDispatcher*>(dispatcher); |
206 dispatcher_->ppb_proxy()->AddRefModule(dispatcher_->pp_module()); | 207 dispatcher_->ppb_proxy()->AddRefModule(dispatcher_->pp_module()); |
207 } | 208 } |
208 | 209 |
209 ScopedModuleReference::~ScopedModuleReference() { | 210 ScopedModuleReference::~ScopedModuleReference() { |
210 dispatcher_->ppb_proxy()->ReleaseModule(dispatcher_->pp_module()); | 211 dispatcher_->ppb_proxy()->ReleaseModule(dispatcher_->pp_module()); |
211 } | 212 } |
212 | 213 |
213 } // namespace proxy | 214 } // namespace proxy |
214 } // namespace ppapi | 215 } // namespace ppapi |
OLD | NEW |