OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" | 9 #include "base/logging.h" |
10 #include "ppapi/c/private/ppb_proxy_private.h" | 10 #include "ppapi/c/private/ppb_proxy_private.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( | 66 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( |
67 instance); | 67 instance); |
68 if (found != g_instance_to_dispatcher->end()) | 68 if (found != g_instance_to_dispatcher->end()) |
69 g_instance_to_dispatcher->erase(found); | 69 g_instance_to_dispatcher->erase(found); |
70 } | 70 } |
71 | 71 |
72 bool HostDispatcher::IsPlugin() const { | 72 bool HostDispatcher::IsPlugin() const { |
73 return false; | 73 return false; |
74 } | 74 } |
75 | 75 |
76 bool HostDispatcher::Send(IPC::Message* msg) { | |
77 // Clear the unblock flag for all messages from the host to the plugin. | |
78 // | |
79 // This prevents reentrancy in the plugin when both sides send sync messages. | |
80 // Since the plugin dispatcher does NOT do this, we won't get a deadlock, | |
81 // but can get reentrancy in the host. | |
82 // | |
83 // This is a temporary workaround until all plugin messages can be made | |
84 // non-blocking (which is a much better solution). It's preferrable to the | |
85 // alternatives because in general plugin -> host sync messages interact with | |
86 // the pepper implementation which is reasonably reentrant. On the other | |
piman
2011/03/07 21:01:29
Well, technically the browser side needs to be ree
| |
87 // hand, the plugin will not expect an input event from inside a call to | |
88 // CreateResource. | |
89 msg->set_unblock(false); | |
piman
2011/03/07 21:01:29
So, this is in general ok, and what we want, but t
| |
90 return Dispatcher::Send(msg); | |
91 } | |
92 | |
76 bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { | 93 bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { |
77 // Handle common control messages. | 94 // Handle common control messages. |
78 if (Dispatcher::OnMessageReceived(msg)) | 95 if (Dispatcher::OnMessageReceived(msg)) |
79 return true; | 96 return true; |
80 | 97 |
81 if (msg.routing_id() <= 0 && msg.routing_id() >= INTERFACE_ID_COUNT) { | 98 if (msg.routing_id() <= 0 && msg.routing_id() >= INTERFACE_ID_COUNT) { |
82 NOTREACHED(); | 99 NOTREACHED(); |
83 // TODO(brettw): kill the plugin if it starts sending invalid messages? | 100 // TODO(brettw): kill the plugin if it starts sending invalid messages? |
84 return true; | 101 return true; |
85 } | 102 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 } | 188 } |
172 | 189 |
173 InterfaceProxy* proxy = info->create_proxy(this, local_interface); | 190 InterfaceProxy* proxy = info->create_proxy(this, local_interface); |
174 target_proxies_[info->id].reset(proxy); | 191 target_proxies_[info->id].reset(proxy); |
175 return proxy; | 192 return proxy; |
176 } | 193 } |
177 | 194 |
178 } // namespace proxy | 195 } // namespace proxy |
179 } // namespace pp | 196 } // namespace pp |
180 | 197 |
OLD | NEW |