| 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_var_tracker.h" | 5 #include "ppapi/proxy/plugin_var_tracker.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 #include "ppapi/c/dev/ppp_class_deprecated.h" | 10 #include "ppapi/c/dev/ppp_class_deprecated.h" |
| 11 #include "ppapi/c/ppb_var.h" | 11 #include "ppapi/c/ppb_var.h" |
| 12 #include "ppapi/proxy/file_system_resource.h" | 12 #include "ppapi/proxy/file_system_resource.h" |
| 13 #include "ppapi/proxy/media_stream_video_track_resource.h" |
| 13 #include "ppapi/proxy/plugin_array_buffer_var.h" | 14 #include "ppapi/proxy/plugin_array_buffer_var.h" |
| 14 #include "ppapi/proxy/plugin_dispatcher.h" | 15 #include "ppapi/proxy/plugin_dispatcher.h" |
| 15 #include "ppapi/proxy/plugin_globals.h" | 16 #include "ppapi/proxy/plugin_globals.h" |
| 16 #include "ppapi/proxy/plugin_resource_var.h" | 17 #include "ppapi/proxy/plugin_resource_var.h" |
| 17 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| 18 #include "ppapi/proxy/proxy_object_var.h" | 19 #include "ppapi/proxy/proxy_object_var.h" |
| 19 #include "ppapi/shared_impl/api_id.h" | 20 #include "ppapi/shared_impl/api_id.h" |
| 20 #include "ppapi/shared_impl/ppapi_globals.h" | 21 #include "ppapi/shared_impl/ppapi_globals.h" |
| 21 #include "ppapi/shared_impl/proxy_lock.h" | 22 #include "ppapi/shared_impl/proxy_lock.h" |
| 22 #include "ppapi/shared_impl/resource_tracker.h" | 23 #include "ppapi/shared_impl/resource_tracker.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 166 |
| 166 // Now just release the object given the plugin var ID. | 167 // Now just release the object given the plugin var ID. |
| 167 ReleaseVar(found->second); | 168 ReleaseVar(found->second); |
| 168 } | 169 } |
| 169 | 170 |
| 170 PP_Var PluginVarTracker::MakeResourcePPVarFromMessage( | 171 PP_Var PluginVarTracker::MakeResourcePPVarFromMessage( |
| 171 PP_Instance instance, | 172 PP_Instance instance, |
| 172 const IPC::Message& creation_message, | 173 const IPC::Message& creation_message, |
| 173 int pending_renderer_id, | 174 int pending_renderer_id, |
| 174 int pending_browser_id) { | 175 int pending_browser_id) { |
| 175 DCHECK(pending_renderer_id); | |
| 176 DCHECK(pending_browser_id); | |
| 177 switch (creation_message.type()) { | 176 switch (creation_message.type()) { |
| 178 case PpapiPluginMsg_FileSystem_CreateFromPendingHost::ID: { | 177 case PpapiPluginMsg_FileSystem_CreateFromPendingHost::ID: { |
| 178 DCHECK(pending_renderer_id); |
| 179 DCHECK(pending_browser_id); |
| 179 PP_FileSystemType file_system_type; | 180 PP_FileSystemType file_system_type; |
| 180 if (!UnpackMessage<PpapiPluginMsg_FileSystem_CreateFromPendingHost>( | 181 if (!UnpackMessage<PpapiPluginMsg_FileSystem_CreateFromPendingHost>( |
| 181 creation_message, &file_system_type)) { | 182 creation_message, &file_system_type)) { |
| 182 NOTREACHED() << "Invalid message of type " | 183 NOTREACHED() << "Invalid message of type " |
| 183 "PpapiPluginMsg_FileSystem_CreateFromPendingHost"; | 184 "PpapiPluginMsg_FileSystem_CreateFromPendingHost"; |
| 184 return PP_MakeNull(); | 185 return PP_MakeNull(); |
| 185 } | 186 } |
| 186 // Create a plugin-side resource and attach it to the host resource. | 187 // Create a plugin-side resource and attach it to the host resource. |
| 187 // Note: This only makes sense when the plugin is out of process (which | 188 // Note: This only makes sense when the plugin is out of process (which |
| 188 // should always be true when passing resource vars). | 189 // should always be true when passing resource vars). |
| 189 PP_Resource pp_resource = | 190 PP_Resource pp_resource = |
| 190 (new FileSystemResource(GetConnectionForInstance(instance), | 191 (new FileSystemResource(GetConnectionForInstance(instance), |
| 191 instance, | 192 instance, |
| 192 pending_renderer_id, | 193 pending_renderer_id, |
| 193 pending_browser_id, | 194 pending_browser_id, |
| 194 file_system_type))->GetReference(); | 195 file_system_type))->GetReference(); |
| 195 return MakeResourcePPVar(pp_resource); | 196 return MakeResourcePPVar(pp_resource); |
| 196 } | 197 } |
| 198 case PpapiPluginMsg_MediaStreamVideoTrack_CreateFromPendingHost::ID: { |
| 199 DCHECK(pending_renderer_id); |
| 200 std::string id; |
| 201 if (!UnpackMessage< |
| 202 PpapiPluginMsg_MediaStreamVideoTrack_CreateFromPendingHost>( |
| 203 creation_message, &id)) { |
| 204 NOTREACHED() << |
| 205 "Invalid message of type " |
| 206 "PpapiPluginMsg_MediaStreamVideoTrack_CreateFromPendingHost"; |
| 207 return PP_MakeNull(); |
| 208 } |
| 209 MediaStreamVideoTrackResource *resource = |
| 210 new MediaStreamVideoTrackResource(GetConnectionForInstance(instance), |
| 211 instance, pending_renderer_id, id); |
| 212 return MakeResourcePPVar(resource->GetReference()); |
| 213 } |
| 197 default: { | 214 default: { |
| 198 NOTREACHED() << "Creation message has unexpected type " | 215 NOTREACHED() << "Creation message has unexpected type " |
| 199 << creation_message.type(); | 216 << creation_message.type(); |
| 200 return PP_MakeNull(); | 217 return PP_MakeNull(); |
| 201 } | 218 } |
| 202 } | 219 } |
| 203 } | 220 } |
| 204 | 221 |
| 205 ResourceVar* PluginVarTracker::MakeResourceVar(PP_Resource pp_resource) { | 222 ResourceVar* PluginVarTracker::MakeResourceVar(PP_Resource pp_resource) { |
| 206 // The resource 0 returns a null resource var. | 223 // The resource 0 returns a null resource var. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 int id, | 487 int id, |
| 471 PP_Instance instance, | 488 PP_Instance instance, |
| 472 base::SharedMemoryHandle* handle, | 489 base::SharedMemoryHandle* handle, |
| 473 uint32* size_in_bytes) { | 490 uint32* size_in_bytes) { |
| 474 NOTREACHED(); | 491 NOTREACHED(); |
| 475 return false; | 492 return false; |
| 476 } | 493 } |
| 477 | 494 |
| 478 } // namesace proxy | 495 } // namesace proxy |
| 479 } // namespace ppapi | 496 } // namespace ppapi |
| OLD | NEW |