| 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_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 14 matching lines...) Expand all Loading... |
| 25 namespace IPC { | 25 namespace IPC { |
| 26 class SyncChannel; | 26 class SyncChannel; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace ppapi { | 29 namespace ppapi { |
| 30 | 30 |
| 31 struct Preferences; | 31 struct Preferences; |
| 32 | 32 |
| 33 namespace proxy { | 33 namespace proxy { |
| 34 | 34 |
| 35 class InterfaceProxy; | |
| 36 class VarSerialization; | 35 class VarSerialization; |
| 37 | 36 |
| 38 class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { | 37 class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { |
| 39 public: | 38 public: |
| 40 // Constructor for the renderer side. | 39 // Constructor for the renderer side. |
| 41 // | 40 // |
| 42 // You must call InitHostWithChannel after the constructor. | 41 // You must call InitHostWithChannel after the constructor. |
| 43 HostDispatcher(base::ProcessHandle host_process_handle, | 42 HostDispatcher(base::ProcessHandle host_process_handle, |
| 44 PP_Module module, | 43 PP_Module module, |
| 45 GetInterfaceFunc local_get_interface); | 44 GetInterfaceFunc local_get_interface); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 73 virtual bool Send(IPC::Message* msg); | 72 virtual bool Send(IPC::Message* msg); |
| 74 | 73 |
| 75 // IPC::Channel::Listener. | 74 // IPC::Channel::Listener. |
| 76 virtual bool OnMessageReceived(const IPC::Message& msg); | 75 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 77 virtual void OnChannelError(); | 76 virtual void OnChannelError(); |
| 78 | 77 |
| 79 // Proxied version of calling GetInterface on the plugin. This will check | 78 // Proxied version of calling GetInterface on the plugin. This will check |
| 80 // if the plugin supports the given interface (with caching) and returns the | 79 // if the plugin supports the given interface (with caching) and returns the |
| 81 // pointer to the proxied interface if it is supported. Returns NULL if the | 80 // pointer to the proxied interface if it is supported. Returns NULL if the |
| 82 // given interface isn't supported by the plugin or the proxy. | 81 // given interface isn't supported by the plugin or the proxy. |
| 83 const void* GetProxiedInterface(const std::string& proxied_interface); | 82 const void* GetProxiedInterface(const std::string& iface_name); |
| 84 | |
| 85 // Returns the proxy object associated with the given interface ID, creating | |
| 86 // it if necessary. This is used in cases where a proxy needs to access code | |
| 87 // in the proxy for another interface. It's assumed that the interface always | |
| 88 // exists, so this is only used for browser proxies. | |
| 89 // | |
| 90 // Will return NULL if an interface isn't supported. | |
| 91 InterfaceProxy* GetOrCreatePPBInterfaceProxy(InterfaceID id); | |
| 92 | 83 |
| 93 // See the value below. Call this when processing a scripting message from | 84 // See the value below. Call this when processing a scripting message from |
| 94 // the plugin that can be reentered. | 85 // the plugin that can be reentered. This is set to false at the beginning |
| 86 // of processing of each message from the plugin. |
| 95 void set_allow_plugin_reentrancy() { | 87 void set_allow_plugin_reentrancy() { |
| 96 allow_plugin_reentrancy_ = true; | 88 allow_plugin_reentrancy_ = true; |
| 97 } | 89 } |
| 98 | 90 |
| 99 // Returns the proxy interface for talking to the implementation. | 91 // Returns the proxy interface for talking to the implementation. |
| 100 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } | 92 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } |
| 101 | 93 |
| 94 protected: |
| 95 // Overridden from Dispatcher. |
| 96 virtual void OnInvalidMessageReceived(); |
| 97 |
| 102 private: | 98 private: |
| 103 friend class HostDispatcherTest; | |
| 104 | |
| 105 // Makes an instance of the given PPB interface proxy, storing it in the | |
| 106 // target_proxies_ array. An proxy for this interface must not exist yet. | |
| 107 InterfaceProxy* CreatePPBInterfaceProxy(const InterfaceProxy::Info* info); | |
| 108 | |
| 109 PP_Module pp_module_; | 99 PP_Module pp_module_; |
| 110 | 100 |
| 111 typedef std::map<std::string, bool> PluginIFSupportedMap; | |
| 112 // Maps interface name to whether that interface is supported. If an interface | 101 // Maps interface name to whether that interface is supported. If an interface |
| 113 // name is not in the map, that implies that we haven't queried for it yet. | 102 // name is not in the map, that implies that we haven't queried for it yet. |
| 114 std::map<std::string, bool> plugin_if_supported_; | 103 typedef base::hash_map<std::string, bool> PluginSupportedMap; |
| 115 | 104 PluginSupportedMap plugin_supported_; |
| 116 // All target proxies currently created. These are ones that receive | |
| 117 // messages. They are created on demand when we receive messages. | |
| 118 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; | |
| 119 | |
| 120 // Function proxies created for "new-style" FunctionGroups. | |
| 121 // TODO(brettw) this is in progress. It should be merged with the target | |
| 122 // proxies so there is one list to consult. | |
| 123 scoped_ptr<FunctionGroupBase> function_proxies_[INTERFACE_ID_COUNT]; | |
| 124 | 105 |
| 125 // Guaranteed non-NULL. | 106 // Guaranteed non-NULL. |
| 126 const PPB_Proxy_Private* ppb_proxy_; | 107 const PPB_Proxy_Private* ppb_proxy_; |
| 127 | 108 |
| 128 // Set to true when the plugin is in a state that it can be reentered by a | 109 // Set to true when the plugin is in a state that it can be reentered by a |
| 129 // sync message from the host. We allow reentrancy only when we're processing | 110 // sync message from the host. We allow reentrancy only when we're processing |
| 130 // a sync message from the renderer that is a scripting command. When the | 111 // a sync message from the renderer that is a scripting command. When the |
| 131 // plugin is in this state, it needs to accept reentrancy since scripting may | 112 // plugin is in this state, it needs to accept reentrancy since scripting may |
| 132 // ultimately call back into the plugin. | 113 // ultimately call back into the plugin. |
| 133 bool allow_plugin_reentrancy_; | 114 bool allow_plugin_reentrancy_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 private: | 130 private: |
| 150 HostDispatcher* dispatcher_; | 131 HostDispatcher* dispatcher_; |
| 151 | 132 |
| 152 DISALLOW_COPY_AND_ASSIGN(ScopedModuleReference); | 133 DISALLOW_COPY_AND_ASSIGN(ScopedModuleReference); |
| 153 }; | 134 }; |
| 154 | 135 |
| 155 } // namespace proxy | 136 } // namespace proxy |
| 156 } // namespace ppapi | 137 } // namespace ppapi |
| 157 | 138 |
| 158 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 139 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
| OLD | NEW |