| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file contains definitions for CppBoundClass | 5 // This file contains definitions for CppBoundClass |
| 6 | 6 |
| 7 // Here's the control flow of a JS method getting forwarded to a class. | 7 // Here's the control flow of a JS method getting forwarded to a class. |
| 8 // - Something calls our NPObject with a function like "Invoke". | 8 // - Something calls our NPObject with a function like "Invoke". |
| 9 // - CppNPObject's static invoke() function forwards it to its attached | 9 // - CppNPObject's static invoke() function forwards it to its attached |
| 10 // CppBoundClass's Invoke() method. | 10 // CppBoundClass's Invoke() method. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return obj->bound_class->GetProperty(ident, result); | 166 return obj->bound_class->GetProperty(ident, result); |
| 167 } | 167 } |
| 168 | 168 |
| 169 /* static */ bool CppNPObject::setProperty(NPObject* np_obj, | 169 /* static */ bool CppNPObject::setProperty(NPObject* np_obj, |
| 170 NPIdentifier ident, | 170 NPIdentifier ident, |
| 171 const NPVariant* value) { | 171 const NPVariant* value) { |
| 172 CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); | 172 CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); |
| 173 return obj->bound_class->SetProperty(ident, value); | 173 return obj->bound_class->SetProperty(ident, value); |
| 174 } | 174 } |
| 175 | 175 |
| 176 CppBoundClass::CppBoundClass() |
| 177 : bound_to_frame_(false) { |
| 178 } |
| 179 |
| 176 CppBoundClass::~CppBoundClass() { | 180 CppBoundClass::~CppBoundClass() { |
| 177 for (MethodList::iterator i = methods_.begin(); i != methods_.end(); ++i) | 181 for (MethodList::iterator i = methods_.begin(); i != methods_.end(); ++i) |
| 178 delete i->second; | 182 delete i->second; |
| 179 | 183 |
| 180 for (PropertyList::iterator i = properties_.begin(); i != properties_.end(); | 184 for (PropertyList::iterator i = properties_.begin(); i != properties_.end(); |
| 181 ++i) { | 185 ++i) { |
| 182 delete i->second; | 186 delete i->second; |
| 183 } | 187 } |
| 184 | 188 |
| 185 // Unregister ourselves if we were bound to a frame. | 189 // Unregister ourselves if we were bound to a frame. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 JSC::JSLock lock(false); | 325 JSC::JSLock lock(false); |
| 322 #endif | 326 #endif |
| 323 | 327 |
| 324 // BindToWindowObject will take its own reference to the NPObject, and clean | 328 // BindToWindowObject will take its own reference to the NPObject, and clean |
| 325 // up after itself. It will also (indirectly) register the object with V8, | 329 // up after itself. It will also (indirectly) register the object with V8, |
| 326 // so we must remember this so we can unregister it when we're destroyed. | 330 // so we must remember this so we can unregister it when we're destroyed. |
| 327 frame->bindToWindowObject(WideToUTF16Hack(classname), | 331 frame->bindToWindowObject(WideToUTF16Hack(classname), |
| 328 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); | 332 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); |
| 329 bound_to_frame_ = true; | 333 bound_to_frame_ = true; |
| 330 } | 334 } |
| OLD | NEW |