| 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 23 matching lines...) Expand all Loading... |
| 34 class HostDispatcher : public Dispatcher { | 34 class HostDispatcher : public Dispatcher { |
| 35 public: | 35 public: |
| 36 // Constructor for the renderer side. | 36 // Constructor for the renderer side. |
| 37 // | 37 // |
| 38 // You must call Dispatcher::InitWithChannel after the constructor. | 38 // You must call Dispatcher::InitWithChannel after the constructor. |
| 39 HostDispatcher(base::ProcessHandle host_process_handle, | 39 HostDispatcher(base::ProcessHandle host_process_handle, |
| 40 PP_Module module, | 40 PP_Module module, |
| 41 GetInterfaceFunc local_get_interface); | 41 GetInterfaceFunc local_get_interface); |
| 42 ~HostDispatcher(); | 42 ~HostDispatcher(); |
| 43 | 43 |
| 44 // Calls the plugin's PPP_InitializeModule function and returns true if | |
| 45 // the call succeeded. | |
| 46 bool InitializeModule(); | |
| 47 | |
| 48 // The host side maintains a mapping from PP_Instance to Dispatcher so | 44 // The host side maintains a mapping from PP_Instance to Dispatcher so |
| 49 // that we can send the messages to the right channel. | 45 // that we can send the messages to the right channel. |
| 50 static HostDispatcher* GetForInstance(PP_Instance instance); | 46 static HostDispatcher* GetForInstance(PP_Instance instance); |
| 51 static void SetForInstance(PP_Instance instance, | 47 static void SetForInstance(PP_Instance instance, |
| 52 HostDispatcher* dispatcher); | 48 HostDispatcher* dispatcher); |
| 53 static void RemoveForInstance(PP_Instance instance); | 49 static void RemoveForInstance(PP_Instance instance); |
| 54 | 50 |
| 51 // Calls the plugin's PPP_InitializeModule function and returns true if |
| 52 // the call succeeded. |
| 53 bool InitializeModule(); |
| 54 |
| 55 // Dispatcher overrides. | 55 // Dispatcher overrides. |
| 56 virtual bool IsPlugin() const; | 56 virtual bool IsPlugin() const; |
| 57 | 57 |
| 58 // IPC::Channel::Listener. |
| 59 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 60 |
| 61 // Proxied version of calling GetInterface on the plugin. This will check |
| 62 // if the plugin supports the given interface (with caching) and returns the |
| 63 // pointer to the proxied interface if it is supported. Returns NULL if the |
| 64 // given interface isn't supported by the plugin or the proxy. |
| 65 const void* GetProxiedInterface(const std::string& interface); |
| 66 |
| 58 private: | 67 private: |
| 68 friend class HostDispatcherTest; |
| 69 |
| 70 enum PluginInterfaceSupport { |
| 71 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. |
| 72 INTERFACE_SUPPORTED, |
| 73 INTERFACE_UNSUPPORTED |
| 74 }; |
| 75 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; |
| 76 |
| 77 // All target proxies currently created. These are ones that receive |
| 78 // messages. They are created on demand when we receive messages. |
| 79 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; |
| 80 |
| 59 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); | 81 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); |
| 60 }; | 82 }; |
| 61 | 83 |
| 62 } // namespace proxy | 84 } // namespace proxy |
| 63 } // namespace pp | 85 } // namespace pp |
| 64 | 86 |
| 65 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 87 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
| OLD | NEW |