Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 69 PP_Module pp_module() const { return pp_module_; } | 68 PP_Module pp_module() const { return pp_module_; } |
| 70 | 69 |
| 71 // Dispatcher overrides. | 70 // Dispatcher overrides. |
| 72 virtual bool IsPlugin() const; | 71 virtual bool IsPlugin() const; |
| 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 |
| 78 // See the value below. Call this when processing a scripting message from | |
| 79 // the plugin that can be reentered. | |
| 80 void set_allow_plugin_reentrancy() { | |
|
noelallen_use_chromium
2011/09/07 21:16:57
I understand this is just a moved block, but isn't
brettw
2011/09/08 05:34:29
I added an additional sentence here and moved it b
| |
| 81 allow_plugin_reentrancy_ = true; | |
| 82 } | |
| 83 | |
| 79 // Proxied version of calling GetInterface on the plugin. This will check | 84 // Proxied version of calling GetInterface on the plugin. This will check |
| 80 // if the plugin supports the given interface (with caching) and returns the | 85 // 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 | 86 // 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. | 87 // given interface isn't supported by the plugin or the proxy. |
| 83 const void* GetProxiedInterface(const std::string& interface); | 88 const void* GetProxiedInterface(const std::string& interface); |
| 84 | 89 |
| 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 | |
| 93 // See the value below. Call this when processing a scripting message from | |
| 94 // the plugin that can be reentered. | |
| 95 void set_allow_plugin_reentrancy() { | |
| 96 allow_plugin_reentrancy_ = true; | |
| 97 } | |
| 98 | |
| 99 // Returns the proxy interface for talking to the implementation. | 90 // Returns the proxy interface for talking to the implementation. |
| 100 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } | 91 const PPB_Proxy_Private* ppb_proxy() const { return ppb_proxy_; } |
| 101 | 92 |
| 93 protected: | |
| 94 // Overridden from Dispatcher. | |
| 95 virtual void OnInvalidMessageReceived(); | |
| 96 | |
| 102 private: | 97 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_; | 98 PP_Module pp_module_; |
| 110 | 99 |
| 111 typedef std::map<std::string, bool> PluginIFSupportedMap; | |
| 112 // Maps interface name to whether that interface is supported. If an interface | 100 // 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. | 101 // 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_; | 102 typedef base::hash_map<std::string, bool> PluginSupportedMap; |
| 115 | 103 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 | 104 |
| 125 // Guaranteed non-NULL. | 105 // Guaranteed non-NULL. |
| 126 const PPB_Proxy_Private* ppb_proxy_; | 106 const PPB_Proxy_Private* ppb_proxy_; |
| 127 | 107 |
| 128 // Set to true when the plugin is in a state that it can be reentered by a | 108 // 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 | 109 // 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 | 110 // 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 | 111 // plugin is in this state, it needs to accept reentrancy since scripting may |
| 132 // ultimately call back into the plugin. | 112 // ultimately call back into the plugin. |
| 133 bool allow_plugin_reentrancy_; | 113 bool allow_plugin_reentrancy_; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 149 private: | 129 private: |
| 150 HostDispatcher* dispatcher_; | 130 HostDispatcher* dispatcher_; |
| 151 | 131 |
| 152 DISALLOW_COPY_AND_ASSIGN(ScopedModuleReference); | 132 DISALLOW_COPY_AND_ASSIGN(ScopedModuleReference); |
| 153 }; | 133 }; |
| 154 | 134 |
| 155 } // namespace proxy | 135 } // namespace proxy |
| 156 } // namespace ppapi | 136 } // namespace ppapi |
| 157 | 137 |
| 158 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 138 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
| OLD | NEW |