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 #ifndef PPAPI_PROXY_HOST_DISPATCHER_H_ | 5 #ifndef PPAPI_PROXY_HOST_DISPATCHER_H_ |
6 #define PPAPI_PROXY_HOST_DISPATCHER_H_ | 6 #define PPAPI_PROXY_HOST_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Returns the host's notion of our PP_Module. This will be different than | 52 // Returns the host's notion of our PP_Module. This will be different than |
53 // the plugin's notion of its PP_Module because the plugin process may be | 53 // the plugin's notion of its PP_Module because the plugin process may be |
54 // used by multiple renderer processes. | 54 // used by multiple renderer processes. |
55 // | 55 // |
56 // Use this value instead of a value from the plugin whenever talking to the | 56 // Use this value instead of a value from the plugin whenever talking to the |
57 // host. | 57 // host. |
58 PP_Module pp_module() const { return pp_module_; } | 58 PP_Module pp_module() const { return pp_module_; } |
59 | 59 |
60 // Dispatcher overrides. | 60 // Dispatcher overrides. |
61 virtual bool IsPlugin() const; | 61 virtual bool IsPlugin() const; |
| 62 virtual bool Send(IPC::Message* msg); |
62 | 63 |
63 // IPC::Channel::Listener. | 64 // IPC::Channel::Listener. |
64 virtual bool OnMessageReceived(const IPC::Message& msg); | 65 virtual bool OnMessageReceived(const IPC::Message& msg); |
65 virtual void OnChannelError(); | 66 virtual void OnChannelError(); |
66 | 67 |
67 // Proxied version of calling GetInterface on the plugin. This will check | 68 // Proxied version of calling GetInterface on the plugin. This will check |
68 // if the plugin supports the given interface (with caching) and returns the | 69 // if the plugin supports the given interface (with caching) and returns the |
69 // pointer to the proxied interface if it is supported. Returns NULL if the | 70 // pointer to the proxied interface if it is supported. Returns NULL if the |
70 // given interface isn't supported by the plugin or the proxy. | 71 // given interface isn't supported by the plugin or the proxy. |
71 const void* GetProxiedInterface(const std::string& interface); | 72 const void* GetProxiedInterface(const std::string& interface); |
72 | 73 |
73 // Returns the proxy object associated with the given interface ID, creating | 74 // Returns the proxy object associated with the given interface ID, creating |
74 // it if necessary. This is used in cases where a proxy needs to access code | 75 // it if necessary. This is used in cases where a proxy needs to access code |
75 // in the proxy for another interface. It's assumed that the interface always | 76 // in the proxy for another interface. It's assumed that the interface always |
76 // exists, so this is only used for browser proxies. | 77 // exists, so this is only used for browser proxies. |
77 // | 78 // |
78 // Will return NULL if an interface isn't supported. | 79 // Will return NULL if an interface isn't supported. |
79 InterfaceProxy* GetOrCreatePPBInterfaceProxy(InterfaceID id); | 80 InterfaceProxy* GetOrCreatePPBInterfaceProxy(InterfaceID id); |
80 | 81 |
| 82 // See the value below. Call this when processing a scripting message from |
| 83 // the plugin that can be reentered. |
| 84 void set_allow_plugin_reentrancy() { |
| 85 allow_plugin_reentrancy_ = true; |
| 86 } |
| 87 |
81 // Returns the proxy interface for talking to the implementation. | 88 // Returns the proxy interface for talking to the implementation. |
82 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } | 89 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } |
83 | 90 |
84 private: | 91 private: |
85 friend class HostDispatcherTest; | 92 friend class HostDispatcherTest; |
86 | 93 |
87 // Makes an instance of the given PPB interface proxy, storing it in the | 94 // Makes an instance of the given PPB interface proxy, storing it in the |
88 // target_proxies_ array. An proxy for this interface must not exist yet. | 95 // target_proxies_ array. An proxy for this interface must not exist yet. |
89 InterfaceProxy* CreatePPBInterfaceProxy(const InterfaceProxy::Info* info); | 96 InterfaceProxy* CreatePPBInterfaceProxy(const InterfaceProxy::Info* info); |
90 | 97 |
91 PP_Module pp_module_; | 98 PP_Module pp_module_; |
92 | 99 |
93 enum PluginInterfaceSupport { | 100 enum PluginInterfaceSupport { |
94 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. | 101 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. |
95 INTERFACE_SUPPORTED, | 102 INTERFACE_SUPPORTED, |
96 INTERFACE_UNSUPPORTED | 103 INTERFACE_UNSUPPORTED |
97 }; | 104 }; |
98 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; | 105 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; |
99 | 106 |
100 // All target proxies currently created. These are ones that receive | 107 // All target proxies currently created. These are ones that receive |
101 // messages. They are created on demand when we receive messages. | 108 // messages. They are created on demand when we receive messages. |
102 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; | 109 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; |
103 | 110 |
104 // Guaranteed non-NULL. | 111 // Guaranteed non-NULL. |
105 const PPB_Proxy_Private* ppb_proxy_; | 112 const PPB_Proxy_Private* ppb_proxy_; |
106 | 113 |
| 114 // Set to true when the plugin is in a state that it can be reentered by a |
| 115 // sync message from the host. We allow reentrancy only when we're processing |
| 116 // a sync message from the renderer that is a scripting command. When the |
| 117 // plugin is in this state, it needs to accept reentrancy since scripting may |
| 118 // ultimately call back into the plugin. |
| 119 bool allow_plugin_reentrancy_; |
| 120 |
107 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); | 121 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); |
108 }; | 122 }; |
109 | 123 |
110 } // namespace proxy | 124 } // namespace proxy |
111 } // namespace pp | 125 } // namespace pp |
112 | 126 |
113 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 127 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
OLD | NEW |