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> |
11 | 11 |
12 #include "base/process.h" | 12 #include "base/process.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
15 #include "ppapi/proxy/dispatcher.h" | 15 #include "ppapi/proxy/dispatcher.h" |
16 #include "ppapi/proxy/plugin_var_tracker.h" | 16 #include "ppapi/proxy/plugin_var_tracker.h" |
17 | 17 |
| 18 struct PPB_Proxy_Private; |
18 struct PPB_Var_Deprecated; | 19 struct PPB_Var_Deprecated; |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class WaitableEvent; | 22 class WaitableEvent; |
22 } | 23 } |
23 | 24 |
24 namespace IPC { | 25 namespace IPC { |
25 class SyncChannel; | 26 class SyncChannel; |
26 } | 27 } |
27 | 28 |
(...skipping 13 matching lines...) Expand all Loading... |
41 GetInterfaceFunc local_get_interface); | 42 GetInterfaceFunc local_get_interface); |
42 ~HostDispatcher(); | 43 ~HostDispatcher(); |
43 | 44 |
44 // The host side maintains a mapping from PP_Instance to Dispatcher so | 45 // The host side maintains a mapping from PP_Instance to Dispatcher so |
45 // that we can send the messages to the right channel. | 46 // that we can send the messages to the right channel. |
46 static HostDispatcher* GetForInstance(PP_Instance instance); | 47 static HostDispatcher* GetForInstance(PP_Instance instance); |
47 static void SetForInstance(PP_Instance instance, | 48 static void SetForInstance(PP_Instance instance, |
48 HostDispatcher* dispatcher); | 49 HostDispatcher* dispatcher); |
49 static void RemoveForInstance(PP_Instance instance); | 50 static void RemoveForInstance(PP_Instance instance); |
50 | 51 |
| 52 // Returns the host's notion of our PP_Module. This will be different than |
| 53 // the plugin's notion of its PP_Module because the plugin process may be |
| 54 // used by multiple renderer processes. |
| 55 // |
| 56 // Use this value instead of a value from the plugin whenever talking to the |
| 57 // host. |
| 58 PP_Module pp_module() const { return pp_module_; } |
| 59 |
51 // Dispatcher overrides. | 60 // Dispatcher overrides. |
52 virtual bool IsPlugin() const; | 61 virtual bool IsPlugin() const; |
53 | 62 |
54 // IPC::Channel::Listener. | 63 // IPC::Channel::Listener. |
55 virtual bool OnMessageReceived(const IPC::Message& msg); | 64 virtual bool OnMessageReceived(const IPC::Message& msg); |
56 virtual void OnChannelError(); | 65 virtual void OnChannelError(); |
57 | 66 |
58 // Proxied version of calling GetInterface on the plugin. This will check | 67 // Proxied version of calling GetInterface on the plugin. This will check |
59 // 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 |
60 // 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 |
61 // given interface isn't supported by the plugin or the proxy. | 70 // given interface isn't supported by the plugin or the proxy. |
62 const void* GetProxiedInterface(const std::string& interface); | 71 const void* GetProxiedInterface(const std::string& interface); |
63 | 72 |
| 73 // Returns the proxy interface for talking to the implementation. |
| 74 const PPB_Proxy_Private* GetPPBProxy(); |
| 75 |
64 private: | 76 private: |
65 friend class HostDispatcherTest; | 77 friend class HostDispatcherTest; |
66 | 78 |
| 79 PP_Module pp_module_; |
| 80 |
67 enum PluginInterfaceSupport { | 81 enum PluginInterfaceSupport { |
68 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. | 82 INTERFACE_UNQUERIED = 0, // Must be 0 so memset(0) will clear the list. |
69 INTERFACE_SUPPORTED, | 83 INTERFACE_SUPPORTED, |
70 INTERFACE_UNSUPPORTED | 84 INTERFACE_UNSUPPORTED |
71 }; | 85 }; |
72 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; | 86 PluginInterfaceSupport plugin_interface_support_[INTERFACE_ID_COUNT]; |
73 | 87 |
74 // All target proxies currently created. These are ones that receive | 88 // All target proxies currently created. These are ones that receive |
75 // messages. They are created on demand when we receive messages. | 89 // messages. They are created on demand when we receive messages. |
76 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; | 90 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; |
77 | 91 |
| 92 // Lazily initialized, may be NULL. Use GetPPBProxy(). |
| 93 const PPB_Proxy_Private* ppb_proxy_; |
| 94 |
78 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); | 95 DISALLOW_COPY_AND_ASSIGN(HostDispatcher); |
79 }; | 96 }; |
80 | 97 |
81 } // namespace proxy | 98 } // namespace proxy |
82 } // namespace pp | 99 } // namespace pp |
83 | 100 |
84 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ | 101 #endif // PPAPI_PROXY_HOST_DISPATCHER_H_ |
OLD | NEW |