| 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 "ppapi/c/dev/ppp_class_deprecated.h" | 9 #include "ppapi/c/dev/ppp_class_deprecated.h" |
| 10 #include "ppapi/c/ppb_var.h" | 10 #include "ppapi/c/ppb_var.h" |
| 11 #include "ppapi/proxy/plugin_array_buffer_var.h" | 11 #include "ppapi/proxy/plugin_array_buffer_var.h" |
| 12 #include "ppapi/proxy/plugin_dispatcher.h" | 12 #include "ppapi/proxy/plugin_dispatcher.h" |
| 13 #include "ppapi/proxy/plugin_resource_var.h" |
| 13 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 14 #include "ppapi/proxy/proxy_object_var.h" | 15 #include "ppapi/proxy/proxy_object_var.h" |
| 15 #include "ppapi/shared_impl/api_id.h" | 16 #include "ppapi/shared_impl/api_id.h" |
| 17 #include "ppapi/shared_impl/ppapi_globals.h" |
| 16 #include "ppapi/shared_impl/proxy_lock.h" | 18 #include "ppapi/shared_impl/proxy_lock.h" |
| 19 #include "ppapi/shared_impl/resource_tracker.h" |
| 17 #include "ppapi/shared_impl/var.h" | 20 #include "ppapi/shared_impl/var.h" |
| 18 | 21 |
| 19 namespace ppapi { | 22 namespace ppapi { |
| 20 namespace proxy { | 23 namespace proxy { |
| 21 | 24 |
| 22 PluginVarTracker::HostVar::HostVar(PluginDispatcher* d, int32 i) | 25 PluginVarTracker::HostVar::HostVar(PluginDispatcher* d, int32 i) |
| 23 : dispatcher(d), | 26 : dispatcher(d), |
| 24 host_object_id(i) { | 27 host_object_id(i) { |
| 25 } | 28 } |
| 26 | 29 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 HostVar(dispatcher, static_cast<int32>(host_object.value.as_id))); | 147 HostVar(dispatcher, static_cast<int32>(host_object.value.as_id))); |
| 145 if (found == host_var_to_plugin_var_.end()) { | 148 if (found == host_var_to_plugin_var_.end()) { |
| 146 NOTREACHED(); | 149 NOTREACHED(); |
| 147 return; | 150 return; |
| 148 } | 151 } |
| 149 | 152 |
| 150 // Now just release the object given the plugin var ID. | 153 // Now just release the object given the plugin var ID. |
| 151 ReleaseVar(found->second); | 154 ReleaseVar(found->second); |
| 152 } | 155 } |
| 153 | 156 |
| 157 ResourceVar* PluginVarTracker::MakeResourceVar(PP_Resource pp_resource) { |
| 158 ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); |
| 159 ppapi::Resource* resource = resource_tracker->GetResource(pp_resource); |
| 160 if (!resource) |
| 161 return NULL; |
| 162 return new PluginResourceVar(resource); |
| 163 } |
| 164 |
| 154 void PluginVarTracker::DidDeleteInstance(PP_Instance instance) { | 165 void PluginVarTracker::DidDeleteInstance(PP_Instance instance) { |
| 155 // Calling the destructors on plugin objects may in turn release other | 166 // Calling the destructors on plugin objects may in turn release other |
| 156 // objects which will mutate the map out from under us. So do a two-step | 167 // objects which will mutate the map out from under us. So do a two-step |
| 157 // process of identifying the ones to delete, and then delete them. | 168 // process of identifying the ones to delete, and then delete them. |
| 158 // | 169 // |
| 159 // See the comment above user_data_to_plugin_ in the header file. We assume | 170 // See the comment above user_data_to_plugin_ in the header file. We assume |
| 160 // there aren't that many objects so a brute-force search is reasonable. | 171 // there aren't that many objects so a brute-force search is reasonable. |
| 161 std::vector<void*> user_data_to_delete; | 172 std::vector<void*> user_data_to_delete; |
| 162 for (UserDataToPluginImplementedVarMap::const_iterator i = | 173 for (UserDataToPluginImplementedVarMap::const_iterator i = |
| 163 user_data_to_plugin_.begin(); | 174 user_data_to_plugin_.begin(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 int id, | 412 int id, |
| 402 PP_Instance instance, | 413 PP_Instance instance, |
| 403 base::SharedMemoryHandle* handle, | 414 base::SharedMemoryHandle* handle, |
| 404 uint32* size_in_bytes) { | 415 uint32* size_in_bytes) { |
| 405 NOTREACHED(); | 416 NOTREACHED(); |
| 406 return false; | 417 return false; |
| 407 } | 418 } |
| 408 | 419 |
| 409 } // namesace proxy | 420 } // namesace proxy |
| 410 } // namespace ppapi | 421 } // namespace ppapi |
| OLD | NEW |