| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> |
| 9 |
| 8 #include <set> | 10 #include <set> |
| 9 #include <string> | 11 #include <string> |
| 10 | 12 |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 13 #include "base/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
| 15 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 16 #include "base/process/process.h" | 18 #include "base/process/process.h" |
| 17 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 18 #include "ipc/ipc_sync_channel.h" | 20 #include "ipc/ipc_sync_channel.h" |
| 19 #include "ppapi/c/pp_instance.h" | 21 #include "ppapi/c/pp_instance.h" |
| 20 #include "ppapi/c/pp_rect.h" | 22 #include "ppapi/c/pp_rect.h" |
| 21 #include "ppapi/c/ppb_console.h" | 23 #include "ppapi/c/ppb_console.h" |
| 22 #include "ppapi/proxy/dispatcher.h" | 24 #include "ppapi/proxy/dispatcher.h" |
| 23 #include "ppapi/proxy/message_handler.h" | 25 #include "ppapi/proxy/message_handler.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // The message handler which should handle JavaScript->Plugin messages, if | 69 // The message handler which should handle JavaScript->Plugin messages, if |
| 68 // one has been registered, otherwise NULL. | 70 // one has been registered, otherwise NULL. |
| 69 scoped_ptr<MessageHandler> message_handler; | 71 scoped_ptr<MessageHandler> message_handler; |
| 70 | 72 |
| 71 // Flush info for PpapiCommandBufferProxy::OrderingBarrier(). | 73 // Flush info for PpapiCommandBufferProxy::OrderingBarrier(). |
| 72 struct FlushInfo { | 74 struct FlushInfo { |
| 73 FlushInfo(); | 75 FlushInfo(); |
| 74 ~FlushInfo(); | 76 ~FlushInfo(); |
| 75 bool flush_pending; | 77 bool flush_pending; |
| 76 HostResource resource; | 78 HostResource resource; |
| 77 int32 put_offset; | 79 int32_t put_offset; |
| 78 }; | 80 }; |
| 79 FlushInfo flush_info_; | 81 FlushInfo flush_info_; |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 class PPAPI_PROXY_EXPORT PluginDispatcher | 84 class PPAPI_PROXY_EXPORT PluginDispatcher |
| 83 : public Dispatcher, | 85 : public Dispatcher, |
| 84 public base::SupportsWeakPtr<PluginDispatcher> { | 86 public base::SupportsWeakPtr<PluginDispatcher> { |
| 85 public: | 87 public: |
| 86 class PPAPI_PROXY_EXPORT PluginDelegate : public ProxyChannel::Delegate { | 88 class PPAPI_PROXY_EXPORT PluginDelegate : public ProxyChannel::Delegate { |
| 87 public: | 89 public: |
| 88 // Returns the set used for globally uniquifying PP_Instances. This same | 90 // Returns the set used for globally uniquifying PP_Instances. This same |
| 89 // set must be returned for all channels. | 91 // set must be returned for all channels. |
| 90 // | 92 // |
| 91 // DEREFERENCE ONLY ON THE I/O THREAD. | 93 // DEREFERENCE ONLY ON THE I/O THREAD. |
| 92 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() = 0; | 94 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() = 0; |
| 93 | 95 |
| 94 // Registers the plugin dispatcher and returns an ID. | 96 // Registers the plugin dispatcher and returns an ID. |
| 95 // Plugin dispatcher IDs will be used to dispatch messages from the browser. | 97 // Plugin dispatcher IDs will be used to dispatch messages from the browser. |
| 96 // Each call to Register() has to be matched with a call to Unregister(). | 98 // Each call to Register() has to be matched with a call to Unregister(). |
| 97 virtual uint32 Register(PluginDispatcher* plugin_dispatcher) = 0; | 99 virtual uint32_t Register(PluginDispatcher* plugin_dispatcher) = 0; |
| 98 virtual void Unregister(uint32 plugin_dispatcher_id) = 0; | 100 virtual void Unregister(uint32_t plugin_dispatcher_id) = 0; |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 // Constructor for the plugin side. The init and shutdown functions will be | 103 // Constructor for the plugin side. The init and shutdown functions will be |
| 102 // will be automatically called when requested by the renderer side. The | 104 // will be automatically called when requested by the renderer side. The |
| 103 // module ID will be set upon receipt of the InitializeModule message. | 105 // module ID will be set upon receipt of the InitializeModule message. |
| 104 // | 106 // |
| 105 // Note about permissions: On the plugin side, the dispatcher and the plugin | 107 // Note about permissions: On the plugin side, the dispatcher and the plugin |
| 106 // run in the same address space (including in nacl). This means that the | 108 // run in the same address space (including in nacl). This means that the |
| 107 // permissions here are subject to malicious modification and bypass, and | 109 // permissions here are subject to malicious modification and bypass, and |
| 108 // an exploited or malicious plugin could send any IPC messages and just | 110 // an exploited or malicious plugin could send any IPC messages and just |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 InstanceData* GetInstanceData(PP_Instance instance); | 176 InstanceData* GetInstanceData(PP_Instance instance); |
| 175 | 177 |
| 176 // Returns the corresponding API. These are APIs not associated with a | 178 // Returns the corresponding API. These are APIs not associated with a |
| 177 // resource. Guaranteed non-NULL. | 179 // resource. Guaranteed non-NULL. |
| 178 thunk::PPB_Instance_API* GetInstanceAPI(); | 180 thunk::PPB_Instance_API* GetInstanceAPI(); |
| 179 thunk::ResourceCreationAPI* GetResourceCreationAPI(); | 181 thunk::ResourceCreationAPI* GetResourceCreationAPI(); |
| 180 | 182 |
| 181 // Returns the Preferences. | 183 // Returns the Preferences. |
| 182 const Preferences& preferences() const { return preferences_; } | 184 const Preferences& preferences() const { return preferences_; } |
| 183 | 185 |
| 184 uint32 plugin_dispatcher_id() const { return plugin_dispatcher_id_; } | 186 uint32_t plugin_dispatcher_id() const { return plugin_dispatcher_id_; } |
| 185 bool incognito() const { return incognito_; } | 187 bool incognito() const { return incognito_; } |
| 186 | 188 |
| 187 private: | 189 private: |
| 188 friend class PluginDispatcherTest; | 190 friend class PluginDispatcherTest; |
| 189 | 191 |
| 190 // Notifies all live instances that they're now closed. This is used when | 192 // Notifies all live instances that they're now closed. This is used when |
| 191 // a renderer crashes or some other error is received. | 193 // a renderer crashes or some other error is received. |
| 192 void ForceFreeAllInstances(); | 194 void ForceFreeAllInstances(); |
| 193 | 195 |
| 194 // IPC message handlers. | 196 // IPC message handlers. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 208 | 210 |
| 209 typedef base::ScopedPtrHashMap<PP_Instance, scoped_ptr<InstanceData>> | 211 typedef base::ScopedPtrHashMap<PP_Instance, scoped_ptr<InstanceData>> |
| 210 InstanceDataMap; | 212 InstanceDataMap; |
| 211 InstanceDataMap instance_map_; | 213 InstanceDataMap instance_map_; |
| 212 | 214 |
| 213 // The preferences sent from the host. We only want to set this once, which | 215 // The preferences sent from the host. We only want to set this once, which |
| 214 // is what the received_preferences_ indicates. See OnMsgSetPreferences. | 216 // is what the received_preferences_ indicates. See OnMsgSetPreferences. |
| 215 bool received_preferences_; | 217 bool received_preferences_; |
| 216 Preferences preferences_; | 218 Preferences preferences_; |
| 217 | 219 |
| 218 uint32 plugin_dispatcher_id_; | 220 uint32_t plugin_dispatcher_id_; |
| 219 | 221 |
| 220 // Set to true when the instances associated with this dispatcher are | 222 // Set to true when the instances associated with this dispatcher are |
| 221 // incognito mode. | 223 // incognito mode. |
| 222 bool incognito_; | 224 bool incognito_; |
| 223 | 225 |
| 224 // A filter for sending messages from threads other than the main thread. | 226 // A filter for sending messages from threads other than the main thread. |
| 225 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 227 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
| 226 | 228 |
| 227 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); | 229 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); |
| 228 }; | 230 }; |
| 229 | 231 |
| 230 } // namespace proxy | 232 } // namespace proxy |
| 231 } // namespace ppapi | 233 } // namespace ppapi |
| 232 | 234 |
| 233 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 235 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
| OLD | NEW |