OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // IPC::Channel::Listener. | 63 // IPC::Channel::Listener. |
64 virtual bool OnMessageReceived(const IPC::Message& msg); | 64 virtual bool OnMessageReceived(const IPC::Message& msg); |
65 virtual void OnChannelError(); | 65 virtual void OnChannelError(); |
66 | 66 |
67 // Proxied version of calling GetInterface on the plugin. This will check | 67 // Proxied version of calling GetInterface on the plugin. This will check |
68 // if the plugin supports the given interface (with caching) and returns the | 68 // if the plugin supports the given interface (with caching) and returns the |
69 // pointer to the proxied interface if it is supported. Returns NULL if the | 69 // pointer to the proxied interface if it is supported. Returns NULL if the |
70 // given interface isn't supported by the plugin or the proxy. | 70 // given interface isn't supported by the plugin or the proxy. |
71 const void* GetProxiedInterface(const std::string& interface); | 71 const void* GetProxiedInterface(const std::string& interface); |
72 | 72 |
| 73 // Returns the proxy object associated with the given interface ID, creating |
| 74 // it if necessary. This is used in cases where a proxy needs to access code |
| 75 // in the proxy for another interface. It's assumed that the interface always |
| 76 // exists, so this is only used for browser proxies. |
| 77 // |
| 78 // Will return NULL if an interface isn't supported. |
| 79 InterfaceProxy* GetOrCreatePPBInterfaceProxy(InterfaceID id); |
| 80 |
73 // Returns the proxy interface for talking to the implementation. | 81 // Returns the proxy interface for talking to the implementation. |
74 const PPB_Proxy_Private* GetPPBProxy(); | 82 const PPB_Proxy_Private* GetPPBProxy(); |
75 | 83 |
76 private: | 84 private: |
77 friend class HostDispatcherTest; | 85 friend class HostDispatcherTest; |
78 | 86 |
| 87 // Makes an instance of the given PPB interface proxy, storing it in the |
| 88 // target_proxies_ array. An proxy for this interface must not exist yet. |
| 89 InterfaceProxy* CreatePPBInterfaceProxy(const InterfaceProxy::Info* info); |
| 90 |
79 PP_Module pp_module_; | 91 PP_Module pp_module_; |
80 | 92 |
81 enum PluginInterfaceSupport { | 93 enum PluginInterfaceSupport { |
82 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. | 94 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. |
83 INTERFACE_SUPPORTED, | 95 INTERFACE_SUPPORTED, |
84 INTERFACE_UNSUPPORTED | 96 INTERFACE_UNSUPPORTED |
85 }; | 97 }; |
86 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; | 98 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; |
87 | 99 |
88 // All target proxies currently created. These are ones that receive | 100 // All target proxies currently created. These are ones that receive |
89 // messages. They are created on demand when we receive messages. | 101 // messages. They are created on demand when we receive messages. |
90 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; | 102 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; |
91 | 103 |
92 // Lazily initialized, may be NULL. Use GetPPBProxy(). | 104 // Lazily initialized, may be NULL. Use GetPPBProxy(). |
93 const PPB_Proxy_Private* ppb_proxy_; | 105 const PPB_Proxy_Private* ppb_proxy_; |
94 | 106 |
95 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); | 107 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); |
96 }; | 108 }; |
97 | 109 |
98 } // namespace proxy | 110 } // namespace proxy |
99 } // namespace pp | 111 } // namespace pp |
100 | 112 |
101 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 113 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
OLD | NEW |