| 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; |
| 35 class VarSerialization; | 36 class VarSerialization; |
| 36 | 37 |
| 37 class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { | 38 class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher { |
| 38 public: | 39 public: |
| 39 // Constructor for the renderer side. | 40 // Constructor for the renderer side. |
| 40 // | 41 // |
| 41 // You must call InitHostWithChannel after the constructor. | 42 // You must call InitHostWithChannel after the constructor. |
| 42 HostDispatcher(base::ProcessHandle host_process_handle, | 43 HostDispatcher(base::ProcessHandle host_process_handle, |
| 43 PP_Module module, | 44 PP_Module module, |
| 44 GetInterfaceFunc local_get_interface); | 45 GetInterfaceFunc local_get_interface); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 virtual bool Send(IPC::Message* msg); | 73 virtual bool Send(IPC::Message* msg); |
| 73 | 74 |
| 74 // IPC::Channel::Listener. | 75 // IPC::Channel::Listener. |
| 75 virtual bool OnMessageReceived(const IPC::Message& msg); | 76 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 76 virtual void OnChannelError(); | 77 virtual void OnChannelError(); |
| 77 | 78 |
| 78 // Proxied version of calling GetInterface on the plugin. This will check | 79 // Proxied version of calling GetInterface on the plugin. This will check |
| 79 // if the plugin supports the given interface (with caching) and returns the | 80 // if the plugin supports the given interface (with caching) and returns the |
| 80 // pointer to the proxied interface if it is supported. Returns NULL if the | 81 // pointer to the proxied interface if it is supported. Returns NULL if the |
| 81 // given interface isn't supported by the plugin or the proxy. | 82 // given interface isn't supported by the plugin or the proxy. |
| 82 const void* GetProxiedInterface(const std::string& iface_name); | 83 const void* GetProxiedInterface(const std::string& proxied_interface); |
| 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); |
| 83 | 92 |
| 84 // See the value below. Call this when processing a scripting message from | 93 // See the value below. Call this when processing a scripting message from |
| 85 // the plugin that can be reentered. This is set to false at the beginning | 94 // the plugin that can be reentered. |
| 86 // of processing of each message from the plugin. | |
| 87 void set_allow_plugin_reentrancy() { | 95 void set_allow_plugin_reentrancy() { |
| 88 allow_plugin_reentrancy_ = true; | 96 allow_plugin_reentrancy_ = true; |
| 89 } | 97 } |
| 90 | 98 |
| 91 // Returns the proxy interface for talking to the implementation. | 99 // Returns the proxy interface for talking to the implementation. |
| 92 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } | 100 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } |
| 93 | 101 |
| 94 protected: | 102 private: |
| 95 // Overridden from Dispatcher. | 103 friend class HostDispatcherTest; |
| 96 virtual void OnInvalidMessageReceived(); | |
| 97 | 104 |
| 98 private: | 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 |
| 99 PP_Module pp_module_; | 109 PP_Module pp_module_; |
| 100 | 110 |
| 111 typedef std::map<std::string, bool> PluginIFSupportedMap; |
| 101 // Maps interface name to whether that interface is supported. If an interface | 112 // Maps interface name to whether that interface is supported. If an interface |
| 102 // name is not in the map, that implies that we haven't queried for it yet. | 113 // name is not in the map, that implies that we haven't queried for it yet. |
| 103 typedef base::hash_map<std::string, bool> PluginSupportedMap; | 114 std::map<std::string, bool> plugin_if_supported_; |
| 104 PluginSupportedMap plugin_supported_; | 115 |
| 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]; |
| 105 | 124 |
| 106 // Guaranteed non-NULL. | 125 // Guaranteed non-NULL. |
| 107 const PPB_Proxy_Private* ppb_proxy_; | 126 const PPB_Proxy_Private* ppb_proxy_; |
| 108 | 127 |
| 109 // Set to true when the plugin is in a state that it can be reentered by a | 128 // Set to true when the plugin is in a state that it can be reentered by a |
| 110 // sync message from the host. We allow reentrancy only when we're processing | 129 // sync message from the host. We allow reentrancy only when we're processing |
| 111 // a sync message from the renderer that is a scripting command. When the | 130 // a sync message from the renderer that is a scripting command. When the |
| 112 // plugin is in this state, it needs to accept reentrancy since scripting may | 131 // plugin is in this state, it needs to accept reentrancy since scripting may |
| 113 // ultimately call back into the plugin. | 132 // ultimately call back into the plugin. |
| 114 bool allow_plugin_reentrancy_; | 133 bool allow_plugin_reentrancy_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 130 private: | 149 private: |
| 131 HostDispatcher* dispatcher_; | 150 HostDispatcher* dispatcher_; |
| 132 | 151 |
| 133 DISALLOW_COPY_AND_ASSIGN(ScopedModuleReference); | 152 DISALLOW_COPY_AND_ASSIGN(ScopedModuleReference); |
| 134 }; | 153 }; |
| 135 | 154 |
| 136 } // namespace proxy | 155 } // namespace proxy |
| 137 } // namespace ppapi | 156 } // namespace ppapi |
| 138 | 157 |
| 139 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 158 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
| OLD | NEW |