OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/plugin_object.h" | 5 #include "webkit/plugins/ppapi/plugin_object.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "third_party/npapi/bindings/npapi.h" | 12 #include "third_party/npapi/bindings/npapi.h" |
13 #include "third_party/npapi/bindings/npruntime.h" | 13 #include "third_party/npapi/bindings/npruntime.h" |
14 #include "ppapi/c/dev/ppb_var_deprecated.h" | 14 #include "ppapi/c/dev/ppb_var_deprecated.h" |
15 #include "ppapi/c/dev/ppp_class_deprecated.h" | 15 #include "ppapi/c/dev/ppp_class_deprecated.h" |
16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
17 #include "ppapi/c/pp_var.h" | 17 #include "ppapi/c/pp_var.h" |
18 #include "ppapi/shared_impl/var.h" | 18 #include "ppapi/shared_impl/var.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
20 #include "webkit/plugins/ppapi/npapi_glue.h" | 20 #include "webkit/plugins/ppapi/npapi_glue.h" |
21 #include "webkit/plugins/ppapi/plugin_module.h" | 21 #include "webkit/plugins/ppapi/plugin_module.h" |
22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
23 #include "webkit/plugins/ppapi/resource.h" | 23 #include "webkit/plugins/ppapi/resource.h" |
| 24 #include "webkit/plugins/ppapi/resource_tracker.h" |
24 #include "webkit/plugins/ppapi/string.h" | 25 #include "webkit/plugins/ppapi/string.h" |
25 | 26 |
26 using ppapi::StringVar; | 27 using ppapi::StringVar; |
27 using ppapi::Var; | 28 using ppapi::Var; |
28 using WebKit::WebBindings; | 29 using WebKit::WebBindings; |
29 | 30 |
30 namespace webkit { | 31 namespace webkit { |
31 namespace ppapi { | 32 namespace ppapi { |
32 | 33 |
33 namespace { | 34 namespace { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 NPObjectAccessorWithIdentifier accessor(object, property_name, true); | 130 NPObjectAccessorWithIdentifier accessor(object, property_name, true); |
130 if (!accessor.is_valid()) | 131 if (!accessor.is_valid()) |
131 return false; | 132 return false; |
132 | 133 |
133 PPResultAndExceptionToNPResult result_converter( | 134 PPResultAndExceptionToNPResult result_converter( |
134 accessor.object()->GetNPObject(), NULL); | 135 accessor.object()->GetNPObject(), NULL); |
135 PP_Var value_var = NPVariantToPPVar(accessor.object()->instance(), value); | 136 PP_Var value_var = NPVariantToPPVar(accessor.object()->instance(), value); |
136 accessor.object()->ppp_class()->SetProperty( | 137 accessor.object()->ppp_class()->SetProperty( |
137 accessor.object()->ppp_class_data(), accessor.identifier(), value_var, | 138 accessor.object()->ppp_class_data(), accessor.identifier(), value_var, |
138 result_converter.exception()); | 139 result_converter.exception()); |
139 Var::PluginReleasePPVar(value_var); | 140 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(value_var); |
140 return result_converter.CheckExceptionForNoResult(); | 141 return result_converter.CheckExceptionForNoResult(); |
141 } | 142 } |
142 | 143 |
143 bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) { | 144 bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) { |
144 NPObjectAccessorWithIdentifier accessor(object, property_name, true); | 145 NPObjectAccessorWithIdentifier accessor(object, property_name, true); |
145 if (!accessor.is_valid()) | 146 if (!accessor.is_valid()) |
146 return false; | 147 return false; |
147 | 148 |
148 PPResultAndExceptionToNPResult result_converter( | 149 PPResultAndExceptionToNPResult result_converter( |
149 accessor.object()->GetNPObject(), NULL); | 150 accessor.object()->GetNPObject(), NULL); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 195 } |
195 } | 196 } |
196 } | 197 } |
197 | 198 |
198 // This will actually throw the exception, either from GetAllPropertyNames, | 199 // This will actually throw the exception, either from GetAllPropertyNames, |
199 // or if anything was set during the conversion process. | 200 // or if anything was set during the conversion process. |
200 result_converter.CheckExceptionForNoResult(); | 201 result_converter.CheckExceptionForNoResult(); |
201 | 202 |
202 // Release the PP_Var that the plugin allocated. On success, they will all | 203 // Release the PP_Var that the plugin allocated. On success, they will all |
203 // be converted to NPVariants, and on failure, we want them to just go away. | 204 // be converted to NPVariants, and on failure, we want them to just go away. |
| 205 ::ppapi::VarTracker* var_tracker = ResourceTracker::Get()->GetVarTracker(); |
204 for (uint32_t i = 0; i < property_count; ++i) | 206 for (uint32_t i = 0; i < property_count; ++i) |
205 Var::PluginReleasePPVar(properties[i]); | 207 var_tracker->ReleaseVar(properties[i]); |
206 free(properties); | 208 free(properties); |
207 return result_converter.success(); | 209 return result_converter.success(); |
208 } | 210 } |
209 | 211 |
210 bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, | 212 bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, |
211 uint32_t argc, NPVariant* result) { | 213 uint32_t argc, NPVariant* result) { |
212 PluginObject* obj = PluginObject::FromNPObject(object); | 214 PluginObject* obj = PluginObject::FromNPObject(object); |
213 if (!obj) | 215 if (!obj) |
214 return false; | 216 return false; |
215 | 217 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // static | 335 // static |
334 NPObject* PluginObject::AllocateObjectWrapper() { | 336 NPObject* PluginObject::AllocateObjectWrapper() { |
335 NPObjectWrapper* wrapper = new NPObjectWrapper; | 337 NPObjectWrapper* wrapper = new NPObjectWrapper; |
336 memset(wrapper, 0, sizeof(NPObjectWrapper)); | 338 memset(wrapper, 0, sizeof(NPObjectWrapper)); |
337 return wrapper; | 339 return wrapper; |
338 } | 340 } |
339 | 341 |
340 } // namespace ppapi | 342 } // namespace ppapi |
341 } // namespace webkit | 343 } // namespace webkit |
342 | 344 |
OLD | NEW |