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 #ifndef PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // The plugin side maintains a mapping from PP_Instance to Dispatcher so | 81 // The plugin side maintains a mapping from PP_Instance to Dispatcher so |
82 // that we can send the messages to the right channel if there are multiple | 82 // that we can send the messages to the right channel if there are multiple |
83 // renderers sharing the same plugin. This mapping is maintained by | 83 // renderers sharing the same plugin. This mapping is maintained by |
84 // DidCreateInstance/DidDestroyInstance. | 84 // DidCreateInstance/DidDestroyInstance. |
85 static PluginDispatcher* GetForInstance(PP_Instance instance); | 85 static PluginDispatcher* GetForInstance(PP_Instance instance); |
86 | 86 |
87 // Same as GetForInstance but retrieves the instance from the given resource | 87 // Same as GetForInstance but retrieves the instance from the given resource |
88 // object as a convenience. Returns NULL on failure. | 88 // object as a convenience. Returns NULL on failure. |
89 static PluginDispatcher* GetForResource(const Resource* resource); | 89 static PluginDispatcher* GetForResource(const Resource* resource); |
90 | 90 |
91 static const void* GetInterfaceFromDispatcher( | 91 // Implements the GetInterface function for the plugin to call to retrieve |
92 const char* dispatcher_interface); | 92 // a browser interface. |
| 93 static const void* GetBrowserInterface(const char* interface); |
| 94 |
| 95 const void* GetPluginInterface(const std::string& interface_name); |
93 | 96 |
94 // You must call this function before anything else. Returns true on success. | 97 // You must call this function before anything else. Returns true on success. |
95 // The delegate pointer must outlive this class, ownership is not | 98 // The delegate pointer must outlive this class, ownership is not |
96 // transferred. | 99 // transferred. |
97 bool InitPluginWithChannel(PluginDelegate* delegate, | 100 bool InitPluginWithChannel(PluginDelegate* delegate, |
98 const IPC::ChannelHandle& channel_handle, | 101 const IPC::ChannelHandle& channel_handle, |
99 bool is_client); | 102 bool is_client); |
100 | 103 |
101 // Dispatcher overrides. | 104 // Dispatcher overrides. |
102 virtual bool IsPlugin() const; | 105 virtual bool IsPlugin() const; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Notifies all live instances that they're now closed. This is used when | 145 // Notifies all live instances that they're now closed. This is used when |
143 // a renderer crashes or some other error is received. | 146 // a renderer crashes or some other error is received. |
144 void ForceFreeAllInstances(); | 147 void ForceFreeAllInstances(); |
145 | 148 |
146 // IPC message handlers. | 149 // IPC message handlers. |
147 void OnMsgSupportsInterface(const std::string& interface_name, bool* result); | 150 void OnMsgSupportsInterface(const std::string& interface_name, bool* result); |
148 void OnMsgSetPreferences(const Preferences& prefs); | 151 void OnMsgSetPreferences(const Preferences& prefs); |
149 | 152 |
150 PluginDelegate* plugin_delegate_; | 153 PluginDelegate* plugin_delegate_; |
151 | 154 |
152 // All target proxies currently created. These are ones that receive | 155 // Contains all the plugin interfaces we've queried. The mapped value will |
153 // messages. | 156 // be the pointer to the interface pointer supplied by the plugin if it's |
154 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; | 157 // supported, or NULL if it's not supported. This allows us to cache failures |
155 | 158 // and not req-query if a plugin doesn't support the interface. |
156 // Function proxies created for "new-style" FunctionGroups. | 159 typedef base::hash_map<std::string, const void*> InterfaceMap; |
157 // TODO(brettw) this is in progress. It should be merged with the target | 160 InterfaceMap plugin_interfaces_; |
158 // proxies so there is one list to consult. | |
159 scoped_ptr<FunctionGroupBase> function_proxies_[INTERFACE_ID_COUNT]; | |
160 | 161 |
161 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; | 162 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; |
162 InstanceDataMap instance_map_; | 163 InstanceDataMap instance_map_; |
163 | 164 |
164 // The preferences sent from the host. We only want to set this once, which | 165 // The preferences sent from the host. We only want to set this once, which |
165 // is what the received_preferences_ indicates. See OnMsgSetPreferences. | 166 // is what the received_preferences_ indicates. See OnMsgSetPreferences. |
166 bool received_preferences_; | 167 bool received_preferences_; |
167 Preferences preferences_; | 168 Preferences preferences_; |
168 | 169 |
169 uint32 plugin_dispatcher_id_; | 170 uint32 plugin_dispatcher_id_; |
170 | 171 |
171 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); | 172 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); |
172 }; | 173 }; |
173 | 174 |
174 } // namespace proxy | 175 } // namespace proxy |
175 } // namespace ppapi | 176 } // namespace ppapi |
176 | 177 |
177 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 178 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
OLD | NEW |