Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: ppapi/proxy/plugin_dispatcher.h

Issue 7740038: Use macros to define pepper interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(const char* interface); 91 // Implements the GetInterface function for the plugin to call to retrieve
92 // a browser interface.
93 static const void* GetBrowserInterface(const char* interface);
94
95 const void* GetPluginInterface(const std::string& interface_name);
92 96
93 // 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.
94 // The delegate pointer must outlive this class, ownership is not 98 // The delegate pointer must outlive this class, ownership is not
95 // transferred. 99 // transferred.
96 bool InitPluginWithChannel(PluginDelegate* delegate, 100 bool InitPluginWithChannel(PluginDelegate* delegate,
97 const IPC::ChannelHandle& channel_handle, 101 const IPC::ChannelHandle& channel_handle,
98 bool is_client); 102 bool is_client);
99 103
100 // Dispatcher overrides. 104 // Dispatcher overrides.
101 virtual bool IsPlugin() const; 105 virtual bool IsPlugin() const;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // 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
142 // a renderer crashes or some other error is received. 146 // a renderer crashes or some other error is received.
143 void ForceFreeAllInstances(); 147 void ForceFreeAllInstances();
144 148
145 // IPC message handlers. 149 // IPC message handlers.
146 void OnMsgSupportsInterface(const std::string& interface_name, bool* result); 150 void OnMsgSupportsInterface(const std::string& interface_name, bool* result);
147 void OnMsgSetPreferences(const Preferences& prefs); 151 void OnMsgSetPreferences(const Preferences& prefs);
148 152
149 PluginDelegate* plugin_delegate_; 153 PluginDelegate* plugin_delegate_;
150 154
151 // All target proxies currently created. These are ones that receive 155 // Contains all the plugin interfaces we've queried. The mapped value will
152 // messages. 156 // be the pointer to the interface pointer supplied by the plugin if it's
153 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; 157 // supported, or NULL if it's not supported. This allows us to cache failures
154 158 // and not req-query if a plugin doesn't support the interface.
155 // Function proxies created for "new-style" FunctionGroups. 159 typedef base::hash_map<std::string, const void*> InterfaceMap;
156 // TODO(brettw) this is in progress. It should be merged with the target 160 InterfaceMap plugin_interfaces_;
157 // proxies so there is one list to consult.
158 scoped_ptr<FunctionGroupBase> function_proxies_[INTERFACE_ID_COUNT];
159 161
160 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; 162 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap;
161 InstanceDataMap instance_map_; 163 InstanceDataMap instance_map_;
162 164
163 // 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
164 // is what the received_preferences_ indicates. See OnMsgSetPreferences. 166 // is what the received_preferences_ indicates. See OnMsgSetPreferences.
165 bool received_preferences_; 167 bool received_preferences_;
166 Preferences preferences_; 168 Preferences preferences_;
167 169
168 uint32 plugin_dispatcher_id_; 170 uint32 plugin_dispatcher_id_;
169 171
170 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); 172 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher);
171 }; 173 };
172 174
173 } // namespace proxy 175 } // namespace proxy
174 } // namespace ppapi 176 } // namespace ppapi
175 177
176 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ 178 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698