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_DISPATCHER_H_ | 5 #ifndef PPAPI_PROXY_DISPATCHER_H_ |
6 #define PPAPI_PROXY_DISPATCHER_H_ | 6 #define PPAPI_PROXY_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/linked_ptr.h" | 12 #include "base/linked_ptr.h" |
| 13 #include "base/process.h" |
13 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
14 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
15 #include "ipc/ipc_channel_handle.h" | 16 #include "ipc/ipc_channel_handle.h" |
16 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
17 #include "ppapi/c/pp_module.h" | 18 #include "ppapi/c/pp_module.h" |
18 #include "ppapi/proxy/callback_tracker.h" | 19 #include "ppapi/proxy/callback_tracker.h" |
19 #include "ppapi/proxy/interface_id.h" | 20 #include "ppapi/proxy/interface_id.h" |
20 #include "ppapi/proxy/plugin_resource_tracker.h" | 21 #include "ppapi/proxy/plugin_resource_tracker.h" |
21 #include "ppapi/proxy/plugin_var_tracker.h" | 22 #include "ppapi/proxy/plugin_var_tracker.h" |
22 | 23 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Wrapper for calling the local GetInterface function. | 80 // Wrapper for calling the local GetInterface function. |
80 const void* GetLocalInterface(const char* interface); | 81 const void* GetLocalInterface(const char* interface); |
81 | 82 |
82 // Implements PPP_GetInterface and PPB_GetInterface on the "source" side. It | 83 // Implements PPP_GetInterface and PPB_GetInterface on the "source" side. It |
83 // will check if the remote side supports this interface as a target, and | 84 // will check if the remote side supports this interface as a target, and |
84 // create a proxy if it does. A local implementation of that interface backed | 85 // create a proxy if it does. A local implementation of that interface backed |
85 // by the proxy will be returned on success. If the interface is unproxyable | 86 // by the proxy will be returned on success. If the interface is unproxyable |
86 // or not supported by the remote side, returns NULL. | 87 // or not supported by the remote side, returns NULL. |
87 const void* GetProxiedInterface(const std::string& interface); | 88 const void* GetProxiedInterface(const std::string& interface); |
88 | 89 |
| 90 // Returns the remote process' handle. For the host dispatcher, this will be |
| 91 // the plugin process, and for the plugin dispatcher, this will be the |
| 92 // renderer process. This is used for sharing memory and such and is |
| 93 // guaranteed valid (unless the remote process has suddenly died). |
| 94 base::ProcessHandle remote_process_handle() const { |
| 95 return remote_process_handle_; |
| 96 } |
| 97 |
89 // Called if the remote side is declaring to us which interfaces it supports | 98 // Called if the remote side is declaring to us which interfaces it supports |
90 // so we don't have to query for each one. We'll pre-create proxies for | 99 // so we don't have to query for each one. We'll pre-create proxies for |
91 // each of the given interfaces. | 100 // each of the given interfaces. |
92 | 101 |
93 // IPC::Message::Sender implementation. | 102 // IPC::Message::Sender implementation. |
94 virtual bool Send(IPC::Message* msg); | 103 virtual bool Send(IPC::Message* msg); |
95 | 104 |
96 // IPC::Channel::Listener implementation. | 105 // IPC::Channel::Listener implementation. |
97 virtual void OnMessageReceived(const IPC::Message& msg); | 106 virtual void OnMessageReceived(const IPC::Message& msg); |
98 | 107 |
99 IPC::SyncChannel* channel() const { | 108 IPC::SyncChannel* channel() const { |
100 return channel_.get(); | 109 return channel_.get(); |
101 } | 110 } |
102 | 111 |
103 CallbackTracker& callback_tracker() { | 112 CallbackTracker& callback_tracker() { |
104 return callback_tracker_; | 113 return callback_tracker_; |
105 } | 114 } |
106 | 115 |
107 protected: | 116 protected: |
108 Dispatcher(GetInterfaceFunc local_get_interface); | 117 Dispatcher(base::ProcessHandle remote_process_handle, |
| 118 GetInterfaceFunc local_get_interface); |
109 | 119 |
110 // Setter for the derived classes to set the appropriate var serialization. | 120 // Setter for the derived classes to set the appropriate var serialization. |
111 // Takes ownership of the given pointer, which must be on the heap. | 121 // Takes ownership of the given pointer, which must be on the heap. |
112 void SetSerializationRules(VarSerializationRules* var_serialization_rules); | 122 void SetSerializationRules(VarSerializationRules* var_serialization_rules); |
113 | 123 |
114 void set_pp_module(PP_Module module) { | 124 void set_pp_module(PP_Module module) { |
115 pp_module_ = module; | 125 pp_module_ = module; |
116 } | 126 } |
117 | 127 |
118 // Allows the PluginDispatcher to add a magic proxy for PPP_Class, bypassing | 128 // Allows the PluginDispatcher to add a magic proxy for PPP_Class, bypassing |
(...skipping 28 matching lines...) Expand all Loading... |
147 // Returns true if this process implements the given interface and it is | 157 // Returns true if this process implements the given interface and it is |
148 // proxyable. | 158 // proxyable. |
149 bool SetupProxyForTargetInterface(const std::string& interface); | 159 bool SetupProxyForTargetInterface(const std::string& interface); |
150 | 160 |
151 bool IsInterfaceTrusted(const std::string& interface); | 161 bool IsInterfaceTrusted(const std::string& interface); |
152 | 162 |
153 // Set by the derived classed to indicate the module ID corresponding to | 163 // Set by the derived classed to indicate the module ID corresponding to |
154 // this dispatcher. | 164 // this dispatcher. |
155 PP_Module pp_module_; | 165 PP_Module pp_module_; |
156 | 166 |
| 167 base::ProcessHandle remote_process_handle_; // See getter above. |
157 scoped_ptr<IPC::SyncChannel> channel_; | 168 scoped_ptr<IPC::SyncChannel> channel_; |
158 | 169 |
159 bool disallow_trusted_interfaces_; | 170 bool disallow_trusted_interfaces_; |
160 | 171 |
161 GetInterfaceFunc local_get_interface_; | 172 GetInterfaceFunc local_get_interface_; |
162 | 173 |
163 ProxyMap proxies_; | 174 ProxyMap proxies_; |
164 InterfaceProxy* id_to_proxy_[INTERFACE_ID_COUNT]; | 175 InterfaceProxy* id_to_proxy_[INTERFACE_ID_COUNT]; |
165 | 176 |
166 // True if the remote side has declared which interfaces it supports in | 177 // True if the remote side has declared which interfaces it supports in |
(...skipping 11 matching lines...) Expand all Loading... |
178 | 189 |
179 scoped_ptr<VarSerializationRules> serialization_rules_; | 190 scoped_ptr<VarSerializationRules> serialization_rules_; |
180 | 191 |
181 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 192 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
182 }; | 193 }; |
183 | 194 |
184 } // namespace proxy | 195 } // namespace proxy |
185 } // namespace pp | 196 } // namespace pp |
186 | 197 |
187 #endif // PPAPI_PROXY_DISPATCHER_H_ | 198 #endif // PPAPI_PROXY_DISPATCHER_H_ |
OLD | NEW |