| 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" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 // This object will register itself both with the NPObject and with the | 284 // This object will register itself both with the NPObject and with the |
| 285 // PluginModule. The NPObject will normally handle its lifetime, and it | 285 // PluginModule. The NPObject will normally handle its lifetime, and it |
| 286 // will get deleted in the destroy method. It may also get deleted when the | 286 // will get deleted in the destroy method. It may also get deleted when the |
| 287 // plugin module is deallocated. | 287 // plugin module is deallocated. |
| 288 new PluginObject(instance, wrapper, ppp_class, ppp_class_data); | 288 new PluginObject(instance, wrapper, ppp_class, ppp_class_data); |
| 289 | 289 |
| 290 // We can just use a normal ObjectVar to refer to this object from the | 290 // We can just use a normal ObjectVar to refer to this object from the |
| 291 // plugin. It will hold a ref to the underlying NPObject which will in turn | 291 // plugin. It will hold a ref to the underlying NPObject which will in turn |
| 292 // hold our pluginObject. | 292 // hold our pluginObject. |
| 293 return ObjectVar::NPObjectToPPVar(instance, wrapper); | 293 PP_Var obj_var(ObjectVar::NPObjectToPPVar(instance, wrapper)); |
| 294 |
| 295 // Note that the ObjectVar constructor incremented the reference count, and so |
| 296 // did WebBindings::createObject above. Now that the PP_Var has taken |
| 297 // ownership, we need to release to balance out the createObject reference |
| 298 // count bump. |
| 299 WebBindings::releaseObject(wrapper); |
| 300 return obj_var; |
| 294 } | 301 } |
| 295 | 302 |
| 296 NPObject* PluginObject::GetNPObject() const { | 303 NPObject* PluginObject::GetNPObject() const { |
| 297 return object_wrapper_; | 304 return object_wrapper_; |
| 298 } | 305 } |
| 299 | 306 |
| 300 // static | 307 // static |
| 301 bool PluginObject::IsInstanceOf(NPObject* np_object, | 308 bool PluginObject::IsInstanceOf(NPObject* np_object, |
| 302 const PPP_Class_Deprecated* ppp_class, | 309 const PPP_Class_Deprecated* ppp_class, |
| 303 void** ppp_class_data) { | 310 void** ppp_class_data) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 325 // static | 332 // static |
| 326 NPObject* PluginObject::AllocateObjectWrapper() { | 333 NPObject* PluginObject::AllocateObjectWrapper() { |
| 327 NPObjectWrapper* wrapper = new NPObjectWrapper; | 334 NPObjectWrapper* wrapper = new NPObjectWrapper; |
| 328 memset(wrapper, 0, sizeof(NPObjectWrapper)); | 335 memset(wrapper, 0, sizeof(NPObjectWrapper)); |
| 329 return wrapper; | 336 return wrapper; |
| 330 } | 337 } |
| 331 | 338 |
| 332 } // namespace ppapi | 339 } // namespace ppapi |
| 333 } // namespace webkit | 340 } // namespace webkit |
| 334 | 341 |
| OLD | NEW |