OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ppapi/proxy/plugin_dispatcher.h" | 5 #include "ppapi/proxy/plugin_dispatcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 thunk::PPB_Instance_API* PluginDispatcher::GetInstanceAPI() { | 253 thunk::PPB_Instance_API* PluginDispatcher::GetInstanceAPI() { |
254 return static_cast<PPB_Instance_Proxy*>( | 254 return static_cast<PPB_Instance_Proxy*>( |
255 GetInterfaceProxy(API_ID_PPB_INSTANCE)); | 255 GetInterfaceProxy(API_ID_PPB_INSTANCE)); |
256 } | 256 } |
257 | 257 |
258 thunk::ResourceCreationAPI* PluginDispatcher::GetResourceCreationAPI() { | 258 thunk::ResourceCreationAPI* PluginDispatcher::GetResourceCreationAPI() { |
259 return static_cast<ResourceCreationProxy*>( | 259 return static_cast<ResourceCreationProxy*>( |
260 GetInterfaceProxy(API_ID_RESOURCE_CREATION)); | 260 GetInterfaceProxy(API_ID_RESOURCE_CREATION)); |
261 } | 261 } |
262 | 262 |
| 263 // static |
| 264 void PluginDispatcher::DispatchResourceReply( |
| 265 const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
| 266 const IPC::Message& nested_msg) { |
| 267 Resource* resource = PpapiGlobals::Get()->GetResourceTracker()->GetResource( |
| 268 reply_params.pp_resource()); |
| 269 if (!resource) { |
| 270 NOTREACHED(); |
| 271 return; |
| 272 } |
| 273 resource->OnReplyReceived(reply_params, nested_msg); |
| 274 } |
| 275 |
263 void PluginDispatcher::ForceFreeAllInstances() { | 276 void PluginDispatcher::ForceFreeAllInstances() { |
264 if (!g_instance_to_dispatcher) | 277 if (!g_instance_to_dispatcher) |
265 return; | 278 return; |
266 | 279 |
267 // Iterating will remove each item from the map, so we need to make a copy | 280 // Iterating will remove each item from the map, so we need to make a copy |
268 // to avoid things changing out from under is. | 281 // to avoid things changing out from under is. |
269 InstanceToDispatcherMap temp_map = *g_instance_to_dispatcher; | 282 InstanceToDispatcherMap temp_map = *g_instance_to_dispatcher; |
270 for (InstanceToDispatcherMap::iterator i = temp_map.begin(); | 283 for (InstanceToDispatcherMap::iterator i = temp_map.begin(); |
271 i != temp_map.end(); ++i) { | 284 i != temp_map.end(); ++i) { |
272 if (i->second == this) { | 285 if (i->second == this) { |
273 // Synthesize an "instance destroyed" message, this will notify the | 286 // Synthesize an "instance destroyed" message, this will notify the |
274 // plugin and also remove it from our list of tracked plugins. | 287 // plugin and also remove it from our list of tracked plugins. |
275 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); | 288 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); |
276 OnMessageReceived(msg); | 289 OnMessageReceived(msg); |
277 } | 290 } |
278 } | 291 } |
279 } | 292 } |
280 | 293 |
281 void PluginDispatcher::OnMsgResourceReply( | 294 void PluginDispatcher::OnMsgResourceReply( |
282 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | 295 const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
283 const IPC::Message& nested_msg) { | 296 const IPC::Message& nested_msg) { |
284 Resource* resource = PpapiGlobals::Get()->GetResourceTracker()->GetResource( | 297 DispatchResourceReply(reply_params, nested_msg); |
285 reply_params.pp_resource()); | |
286 if (!resource) { | |
287 NOTREACHED(); | |
288 return; | |
289 } | |
290 resource->OnReplyReceived(reply_params, nested_msg); | |
291 } | 298 } |
292 | 299 |
293 void PluginDispatcher::OnMsgSupportsInterface( | 300 void PluginDispatcher::OnMsgSupportsInterface( |
294 const std::string& interface_name, | 301 const std::string& interface_name, |
295 bool* result) { | 302 bool* result) { |
296 *result = !!GetPluginInterface(interface_name); | 303 *result = !!GetPluginInterface(interface_name); |
297 | 304 |
298 // Do fallback for PPP_Instance. This is a hack here and if we have more | 305 // Do fallback for PPP_Instance. This is a hack here and if we have more |
299 // cases like this it should be generalized. The PPP_Instance proxy always | 306 // cases like this it should be generalized. The PPP_Instance proxy always |
300 // proxies the 1.1 interface, and then does fallback to 1.0 inside the | 307 // proxies the 1.1 interface, and then does fallback to 1.0 inside the |
(...skipping 12 matching lines...) Expand all Loading... |
313 // once they're set. The user will have to restart to get new font prefs | 320 // once they're set. The user will have to restart to get new font prefs |
314 // propogated to plugins. | 321 // propogated to plugins. |
315 if (!received_preferences_) { | 322 if (!received_preferences_) { |
316 received_preferences_ = true; | 323 received_preferences_ = true; |
317 preferences_ = prefs; | 324 preferences_ = prefs; |
318 } | 325 } |
319 } | 326 } |
320 | 327 |
321 } // namespace proxy | 328 } // namespace proxy |
322 } // namespace ppapi | 329 } // namespace ppapi |
OLD | NEW |